fixes specs
This commit is contained in:
@@ -8,9 +8,9 @@ class ProposalNotification < ActiveRecord::Base
|
|||||||
validate :minimum_interval
|
validate :minimum_interval
|
||||||
|
|
||||||
def minimum_interval
|
def minimum_interval
|
||||||
return true if proposal.notifications.blank?
|
return true if proposal.try(:notifications).blank?
|
||||||
if proposal.notifications.last.created_at > (Time.now - Setting[:proposal_notification_minimum_interval_in_days].to_i.days).to_datetime
|
if proposal.notifications.last.created_at > (Time.now - Setting[:proposal_notification_minimum_interval_in_days].to_i.days).to_datetime
|
||||||
errors.add(:minimum_interval, I18n.t('activerecord.errors.models.proposal_notification.minimum_interval', interval: Setting[:proposal_notification_minimum_interval]))
|
errors.add(:title, I18n.t('activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid', interval: Setting[:proposal_notification_minimum_interval_in_days]))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ search:
|
|||||||
# - '{devise,simple_form}.*'
|
# - '{devise,simple_form}.*'
|
||||||
ignore_missing:
|
ignore_missing:
|
||||||
- 'unauthorized.*'
|
- 'unauthorized.*'
|
||||||
|
- 'activerecord.errors.models.proposal_notification.*'
|
||||||
- 'errors.messages.blank'
|
- 'errors.messages.blank'
|
||||||
- 'errors.messages.taken'
|
- 'errors.messages.taken'
|
||||||
- 'devise.failure.invalid'
|
- 'devise.failure.invalid'
|
||||||
@@ -134,6 +135,7 @@ ignore_unused:
|
|||||||
- 'spending_proposals.index.search_form.*'
|
- 'spending_proposals.index.search_form.*'
|
||||||
- 'notifications.index.comments_on*'
|
- 'notifications.index.comments_on*'
|
||||||
- 'notifications.index.replies_to*'
|
- 'notifications.index.replies_to*'
|
||||||
|
- 'notifications.index.proposal_notification*'
|
||||||
- 'helpers.page_entries_info.*' # kaminari
|
- 'helpers.page_entries_info.*' # kaminari
|
||||||
- 'views.pagination.*' # kaminari
|
- 'views.pagination.*' # kaminari
|
||||||
- 'shared.suggest.*'
|
- 'shared.suggest.*'
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
en:
|
en:
|
||||||
activerecord:
|
activerecord:
|
||||||
errors:
|
|
||||||
models:
|
|
||||||
user:
|
|
||||||
attributes:
|
|
||||||
email:
|
|
||||||
password_already_set: "This user already has a password"
|
|
||||||
models:
|
models:
|
||||||
activity:
|
activity:
|
||||||
one: "activity"
|
one: "activity"
|
||||||
@@ -76,6 +70,10 @@ en:
|
|||||||
title: "Title"
|
title: "Title"
|
||||||
errors:
|
errors:
|
||||||
models:
|
models:
|
||||||
|
user:
|
||||||
|
attributes:
|
||||||
|
email:
|
||||||
|
password_already_set: "This user already has a password"
|
||||||
debate:
|
debate:
|
||||||
attributes:
|
attributes:
|
||||||
tag_list:
|
tag_list:
|
||||||
@@ -86,4 +84,5 @@ en:
|
|||||||
less_than_or_equal_to: "tags must be less than or equal to %{count}"
|
less_than_or_equal_to: "tags must be less than or equal to %{count}"
|
||||||
proposal_notification:
|
proposal_notification:
|
||||||
attributes:
|
attributes:
|
||||||
minimum_interval: "You have to wait a minium of %{interval} days between notifications"
|
minimum_interval:
|
||||||
|
invalid: "You have to wait a minium of %{interval} days between notifications"
|
||||||
@@ -1,11 +1,5 @@
|
|||||||
es:
|
es:
|
||||||
activerecord:
|
activerecord:
|
||||||
errors:
|
|
||||||
models:
|
|
||||||
user:
|
|
||||||
attributes:
|
|
||||||
email:
|
|
||||||
password_already_set: "Este usuario ya tiene una clave asociada"
|
|
||||||
models:
|
models:
|
||||||
activity:
|
activity:
|
||||||
one: "actividad"
|
one: "actividad"
|
||||||
@@ -76,6 +70,10 @@ es:
|
|||||||
title: "Título"
|
title: "Título"
|
||||||
errors:
|
errors:
|
||||||
models:
|
models:
|
||||||
|
user:
|
||||||
|
attributes:
|
||||||
|
email:
|
||||||
|
password_already_set: "Este usuario ya tiene una clave asociada"
|
||||||
debate:
|
debate:
|
||||||
attributes:
|
attributes:
|
||||||
tag_list:
|
tag_list:
|
||||||
@@ -86,4 +84,5 @@ es:
|
|||||||
less_than_or_equal_to: "los temas deben ser menor o igual que %{count}"
|
less_than_or_equal_to: "los temas deben ser menor o igual que %{count}"
|
||||||
proposal_notification:
|
proposal_notification:
|
||||||
attributes:
|
attributes:
|
||||||
minimum_interval: "Debes esperar un mínimo de %{interval} días entre notificaciones"
|
minimum_interval:
|
||||||
|
invalid: "Debes esperar un mínimo de %{interval} días entre notificaciones"
|
||||||
@@ -181,7 +181,7 @@ feature 'Emails' do
|
|||||||
expect(unread_emails_for(author.email).size).to eql parse_email_count(0)
|
expect(unread_emails_for(author.email).size).to eql parse_email_count(0)
|
||||||
|
|
||||||
email = open_last_email
|
email = open_last_email
|
||||||
expect(email).to have_subject("Thank you for supporting my proposal")
|
expect(email).to have_subject("Thank you for supporting my proposal: #{proposal.title}")
|
||||||
expect(email).to have_body_text("Please share it with others so we can make it happen!")
|
expect(email).to have_body_text("Please share it with others so we can make it happen!")
|
||||||
expect(email).to have_body_text(proposal.title)
|
expect(email).to have_body_text(proposal.title)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -86,11 +86,8 @@ feature 'Proposal Notifications' do
|
|||||||
|
|
||||||
context "Limits" do
|
context "Limits" do
|
||||||
|
|
||||||
pending "Cannot send more than one notification within established interval" do
|
pending "Cannot send more than one notification within established interval"
|
||||||
end
|
pending "use timecop to make sure notifications can be sent after time interval"
|
||||||
|
|
||||||
pending "use timecop to make sure notifications can be sent after time interval" do
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user