diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index b0bd18e5b..38bd4bfe5 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -23,9 +23,9 @@ class AccountController < ApplicationController
def account_params
if @account.organization?
- params.require(:account).permit(:phone_number, :email_on_debate_comment, :email_on_comment_reply, organization_attributes: [:name, :responsible_name])
+ params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, organization_attributes: [:name, :responsible_name])
else
- params.require(:account).permit(:username, :email_on_debate_comment, :email_on_comment_reply)
+ params.require(:account).permit(:username, :email_on_comment, :email_on_comment_reply)
end
end
diff --git a/app/models/comment_notifier.rb b/app/models/comment_notifier.rb
index 8a82e9df0..3cceb5c15 100644
--- a/app/models/comment_notifier.rb
+++ b/app/models/comment_notifier.rb
@@ -12,16 +12,16 @@ class CommentNotifier
private
def send_comment_email
- Mailer.comment(@comment).deliver_later if email_on_debate_comment?
+ Mailer.comment(@comment).deliver_later if email_on_comment?
end
def send_reply_email
Mailer.reply(@comment).deliver_later if email_on_comment_reply?
end
- def email_on_debate_comment?
+ def email_on_comment?
commentable_author = @comment.commentable.author
- commentable_author != @author && commentable_author.email_on_debate_comment?
+ commentable_author != @author && commentable_author.email_on_comment?
end
def email_on_comment_reply?
diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb
index e43c424de..1df3e408e 100644
--- a/app/views/account/show.html.erb
+++ b/app/views/account/show.html.erb
@@ -29,25 +29,25 @@
- <% if @account.organization? %>
- <%= f.fields_for :organization do |fo| %>
- <%= fo.text_field :name, autofocus: true, maxlength: Organization.name_max_length, placeholder: t("account.show.organization_name_label") %>
- <%= fo.text_field :responsible_name, autofocus: true, maxlength: Organization.responsible_name_max_length, placeholder: t("account.show.organization_responsible_name_placeholder") %>
- <% end %>
- <%= f.text_field :phone_number, placeholder: t("account.show.phone_number_label") %>
+
+ <% if @account.organization? %>
+ <%= f.fields_for :organization do |fo| %>
+ <%= fo.text_field :name, autofocus: true, maxlength: Organization.name_max_length, placeholder: t("account.show.organization_name_label") %>
+ <%= fo.text_field :responsible_name, autofocus: true, maxlength: Organization.responsible_name_max_length, placeholder: t("account.show.organization_responsible_name_placeholder") %>
+ <% end %>
+ <%= f.text_field :phone_number, placeholder: t("account.show.phone_number_label") %>
<% else %>
- <%= f.text_field :username, maxlength: User.username_max_length, placeholder: t("account.show.username_label") %>
- <% end %>
+ <%= f.text_field :username, maxlength: User.username_max_length, placeholder: t("account.show.username_label") %>
+ <% end %>
<%= t("account.show.notifications")%>
- <%= f.label :email_on_debate_comment do %>
- <%= f.check_box :email_on_debate_comment, label: false %>
- <%= t("account.show.email_on_debate_comment_label") %>
+ <%= f.label :email_on_comment do %>
+ <%= f.check_box :email_on_comment, label: false %>
+ <%= t("account.show.email_on_comment_label") %>
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index b75e11b9f..01de779b6 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -254,8 +254,7 @@ en:
show:
title: "My account"
save_changes_submit: "Save changes"
- email_on_debate_comment_label: "Receive email when someone comments on my debates"
- email_on_proposal_comment_label: "Receive email when someone comments on my proposals"
+ email_on_comment_label: "Receive email when someone comments on my debates or proposals"
email_on_comment_reply_label: "Receive email when someone replies to my comments"
change_credentials_link: "Change my credentials"
avatar: "Avatar"
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 8c08545ad..a057217e6 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -255,8 +255,7 @@ es:
title: "Mi cuenta"
save_changes_submit: "Guardar cambios"
change_credentials_link: "Cambiar mis datos de acceso"
- email_on_debate_comment_label: "Recibir un email cuando alguien comenta en mis debates"
- email_on_proposal_comment_label: "Recibir un email cuando alguien comenta en mis propuestas"
+ email_on_comment_label: "Recibir un email cuando alguien comenta en mis propuestas o debates"
email_on_comment_reply_label: "Recibir un email cuando alguien contesta a mis comentarios"
avatar: "Avatar"
personal: "Datos personales"
diff --git a/db/migrate/20150914114019_change_email_config_field_in_user.rb b/db/migrate/20150914114019_change_email_config_field_in_user.rb
new file mode 100644
index 000000000..90c875d60
--- /dev/null
+++ b/db/migrate/20150914114019_change_email_config_field_in_user.rb
@@ -0,0 +1,5 @@
+class ChangeEmailConfigFieldInUser < ActiveRecord::Migration
+ def change
+ rename_column :users, :email_on_debate_comment, :email_on_comment
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 40408573d..f1cf73855 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150912145218) do
+ActiveRecord::Schema.define(version: 20150914114019) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -258,7 +258,7 @@ ActiveRecord::Schema.define(version: 20150912145218) do
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
- t.boolean "email_on_debate_comment", default: false
+ t.boolean "email_on_comment", default: false
t.boolean "email_on_comment_reply", default: false
t.string "phone_number", limit: 30
t.string "official_position"
diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb
index 93cfe3dd0..e0249072c 100644
--- a/spec/features/account_spec.rb
+++ b/spec/features/account_spec.rb
@@ -33,7 +33,7 @@ feature 'Account' do
visit account_path
fill_in 'account_username', with: 'Larry Bird'
- check 'account_email_on_debate_comment'
+ check 'account_email_on_comment'
check 'account_email_on_comment_reply'
click_button 'Save changes'
@@ -42,7 +42,7 @@ feature 'Account' do
visit account_path
expect(page).to have_selector("input[value='Larry Bird']")
- expect(page).to have_selector("input[id='account_email_on_debate_comment'][value='1']")
+ expect(page).to have_selector("input[id='account_email_on_comment'][value='1']")
expect(page).to have_selector("input[id='account_email_on_comment_reply'][value='1']")
end
@@ -51,7 +51,7 @@ feature 'Account' do
visit account_path
fill_in 'account_organization_attributes_name', with: 'Google'
- check 'account_email_on_debate_comment'
+ check 'account_email_on_comment'
check 'account_email_on_comment_reply'
click_button 'Save changes'
@@ -60,7 +60,7 @@ feature 'Account' do
visit account_path
expect(page).to have_selector("input[value='Google']")
- expect(page).to have_selector("input[id='account_email_on_debate_comment'][value='1']")
+ expect(page).to have_selector("input[id='account_email_on_comment'][value='1']")
expect(page).to have_selector("input[id='account_email_on_comment_reply'][value='1']")
end
diff --git a/spec/features/emails_spec.rb b/spec/features/emails_spec.rb
index b6a9d1db5..1ce4b529f 100644
--- a/spec/features/emails_spec.rb
+++ b/spec/features/emails_spec.rb
@@ -26,7 +26,7 @@ feature 'Emails' do
context 'Debate comments' do
scenario "Send email on debate comment", :js do
- user = create(:user, email_on_debate_comment: true)
+ user = create(:user, email_on_comment: true)
debate = create(:debate, author: user)
comment_on(debate)
@@ -37,7 +37,7 @@ feature 'Emails' do
end
scenario 'Do not send email about own debate comments', :js do
- user = create(:user, email_on_debate_comment: true)
+ user = create(:user, email_on_comment: true)
debate = create(:debate, author: user)
comment_on(debate, user)
@@ -45,7 +45,7 @@ feature 'Emails' do
end
scenario 'Do not send email about debate comment unless set in preferences', :js do
- user = create(:user, email_on_debate_comment: false)
+ user = create(:user, email_on_comment: false)
debate = create(:debate, author: user)
comment_on(debate)
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 756810395..f7ef59121 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -66,9 +66,9 @@ describe User do
end
describe 'preferences' do
- describe 'email_on_debate_comment' do
+ describe 'email_on_comment' do
it 'should be false by default' do
- expect(subject.email_on_debate_comment).to eq(false)
+ expect(subject.email_on_comment).to eq(false)
end
end