diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index f2a553c38..9a0f89bae 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_comment, :email_on_comment_reply, organization_attributes: [:name, :responsible_name]) + params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, organization_attributes: [:name, :responsible_name]) else - params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply) + params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :newsletter) end end diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb index 5acf6eb62..d10cc78c0 100644 --- a/app/views/account/show.html.erb +++ b/app/views/account/show.html.erb @@ -54,6 +54,13 @@ <% end %> +
<%= text_with_links @comment.body %>
+ ++ <%= t("mailers.config.manage_email_subscriptions") %> <%= link_to t("account.show.title"), account_url, style: "color: #2895F1; text-decoration:none;" %> +
diff --git a/app/views/mailer/reply.html.erb b/app/views/mailer/reply.html.erb index 0c1844507..dadb17dfe 100644 --- a/app/views/mailer/reply.html.erb +++ b/app/views/mailer/reply.html.erb @@ -15,4 +15,8 @@<%= text_with_links @reply.body %>
+ ++ <%= t("mailers.config.manage_email_subscriptions") %> <%= link_to t("account.show.title"), account_url, style: "color: #2895F1; text-decoration:none;" %> +
diff --git a/config/locales/en.yml b/config/locales/en.yml index 8f377af1d..7a5f3bd08 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -291,6 +291,7 @@ en: public_activity_label: "Keep my list of activities public" email_on_comment_label: "Notify me by email when someone comments on my proposals or debates" email_on_comment_reply_label: "Notify me by email when someone replies to my comments" + subscription_to_website_newsletter_label: "Receive by email website relevant information" erase_account_link: "Erase my account" personal: "Personal details" username_label: "Username" diff --git a/config/locales/es.yml b/config/locales/es.yml index a1b1952f2..88f21506f 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -291,6 +291,7 @@ es: public_activity_label: "Mostrar públicamente mi lista de actividades" 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" + subscription_to_website_newsletter_label: "Recibir emails con información interesante sobre la web" erase_account_link: "Darme de baja" personal: "Datos personales" username_label: "Nombre de usuario" diff --git a/config/locales/mailers.en.yml b/config/locales/mailers.en.yml index e3f791185..2b4a24ff3 100755 --- a/config/locales/mailers.en.yml +++ b/config/locales/mailers.en.yml @@ -1,5 +1,7 @@ en: mailers: + config: + manage_email_subscriptions: "To stop receiving these emails change your settings in" comment: subject: "Someone has commented on your %{commentable}" hi: "Hi" diff --git a/config/locales/mailers.es.yml b/config/locales/mailers.es.yml index 350c4c423..6bc4e3309 100644 --- a/config/locales/mailers.es.yml +++ b/config/locales/mailers.es.yml @@ -1,5 +1,7 @@ es: mailers: + config: + manage_email_subscriptions: "Puedes dejar de recibir estos emails cambiando tu configuración en" comment: subject: "Alguien ha comentado en tu %{commentable}" hi: "Hola" diff --git a/db/migrate/20151215165824_add_newsletter_subscription_to_users.rb b/db/migrate/20151215165824_add_newsletter_subscription_to_users.rb new file mode 100644 index 000000000..61e741c27 --- /dev/null +++ b/db/migrate/20151215165824_add_newsletter_subscription_to_users.rb @@ -0,0 +1,5 @@ +class AddNewsletterSubscriptionToUsers < ActiveRecord::Migration + def change + add_column :users, :newsletter, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 448fa1a8e..b854a7446 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: 20151111202657) do +ActiveRecord::Schema.define(version: 20151215165824) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -309,6 +309,7 @@ ActiveRecord::Schema.define(version: 20151111202657) do t.string "erase_reason" t.datetime "erased_at" t.boolean "public_activity", default: true + t.boolean "newsletter", default: false end add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree diff --git a/spec/features/emails_spec.rb b/spec/features/emails_spec.rb index b5052d582..f21966a92 100644 --- a/spec/features/emails_spec.rb +++ b/spec/features/emails_spec.rb @@ -63,6 +63,8 @@ feature 'Emails' do expect(email).to have_subject('Someone has commented on your debate') expect(email).to deliver_to(debate.author) expect(email).to have_body_text(debate_path(debate)) + expect(email).to have_body_text(I18n.t("mailers.config.manage_email_subscriptions")) + expect(email).to have_body_text(account_path) end scenario 'Do not send email about own debate comments', :js do @@ -91,6 +93,8 @@ feature 'Emails' do expect(email).to have_subject('Someone has responded to your comment') expect(email).to deliver_to(user) expect(email).to have_body_text(debate_path(Comment.first.commentable)) + expect(email).to have_body_text(I18n.t("mailers.config.manage_email_subscriptions")) + expect(email).to have_body_text(account_path) end scenario "Do not send email about own replies to own comments", :js do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9b654ddb2..a3327c5aa 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -77,6 +77,12 @@ describe User do expect(subject.email_on_comment_reply).to eq(false) end end + + describe 'subscription_to_website_newsletter' do + it 'should be false by default' do + expect(subject.newsletter).to eq(false) + end + end end describe 'OmniAuth' do