diff --git a/app/models/proposal_notification.rb b/app/models/proposal_notification.rb index 11bfea8ae..f73264318 100644 --- a/app/models/proposal_notification.rb +++ b/app/models/proposal_notification.rb @@ -8,9 +8,9 @@ class ProposalNotification < ActiveRecord::Base validate :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 - 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 diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index c849b469e..d24cc6eab 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -95,6 +95,7 @@ search: # - '{devise,simple_form}.*' ignore_missing: - 'unauthorized.*' + - 'activerecord.errors.models.proposal_notification.*' - 'errors.messages.blank' - 'errors.messages.taken' - 'devise.failure.invalid' @@ -134,6 +135,7 @@ ignore_unused: - 'spending_proposals.index.search_form.*' - 'notifications.index.comments_on*' - 'notifications.index.replies_to*' + - 'notifications.index.proposal_notification*' - 'helpers.page_entries_info.*' # kaminari - 'views.pagination.*' # kaminari - 'shared.suggest.*' diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index 1d46596c2..524c8906c 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -1,11 +1,5 @@ en: activerecord: - errors: - models: - user: - attributes: - email: - password_already_set: "This user already has a password" models: activity: one: "activity" @@ -76,6 +70,10 @@ en: title: "Title" errors: models: + user: + attributes: + email: + password_already_set: "This user already has a password" debate: attributes: tag_list: @@ -86,4 +84,5 @@ en: less_than_or_equal_to: "tags must be less than or equal to %{count}" proposal_notification: attributes: - minimum_interval: "You have to wait a minium of %{interval} days between notifications" \ No newline at end of file + minimum_interval: + invalid: "You have to wait a minium of %{interval} days between notifications" \ No newline at end of file diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml index 001be7228..1999631ab 100644 --- a/config/locales/activerecord.es.yml +++ b/config/locales/activerecord.es.yml @@ -1,11 +1,5 @@ es: activerecord: - errors: - models: - user: - attributes: - email: - password_already_set: "Este usuario ya tiene una clave asociada" models: activity: one: "actividad" @@ -76,6 +70,10 @@ es: title: "Título" errors: models: + user: + attributes: + email: + password_already_set: "Este usuario ya tiene una clave asociada" debate: attributes: tag_list: @@ -86,4 +84,5 @@ es: less_than_or_equal_to: "los temas deben ser menor o igual que %{count}" proposal_notification: attributes: - minimum_interval: "Debes esperar un mínimo de %{interval} días entre notificaciones" \ No newline at end of file + minimum_interval: + invalid: "Debes esperar un mínimo de %{interval} días entre notificaciones" \ No newline at end of file diff --git a/spec/features/emails_spec.rb b/spec/features/emails_spec.rb index e61403635..3f2598e1f 100644 --- a/spec/features/emails_spec.rb +++ b/spec/features/emails_spec.rb @@ -181,7 +181,7 @@ feature 'Emails' do expect(unread_emails_for(author.email).size).to eql parse_email_count(0) 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(proposal.title) end diff --git a/spec/features/proposal_notifications_spec.rb b/spec/features/proposal_notifications_spec.rb index 87a717ba2..b0721f874 100644 --- a/spec/features/proposal_notifications_spec.rb +++ b/spec/features/proposal_notifications_spec.rb @@ -86,11 +86,8 @@ feature 'Proposal Notifications' do context "Limits" do - pending "Cannot send more than one notification within established interval" do - end - - pending "use timecop to make sure notifications can be sent after time interval" do - end + pending "Cannot send more than one notification within established interval" + pending "use timecop to make sure notifications can be sent after time interval" end