diff --git a/app/controllers/admin/system_emails_controller.rb b/app/controllers/admin/system_emails_controller.rb index de09c7c1f..da86b1e9a 100644 --- a/app/controllers/admin/system_emails_controller.rb +++ b/app/controllers/admin/system_emails_controller.rb @@ -1,7 +1,22 @@ class Admin::SystemEmailsController < Admin::BaseController + before_action :load_system_email, only: [:view] + def index @system_emails = %w(proposal_notification_digest) end + def view + case @system_email + when "proposal_notification_digest" + @notifications = Notification.where(notifiable_type: "ProposalNotification").limit(2) + @subject = t('mailers.proposal_notification_digest.title', org_name: Setting['org_name']) + end + end + + private + + def load_system_email + @system_email = params[:system_email_id] + end end diff --git a/app/views/admin/system_emails/index.html.erb b/app/views/admin/system_emails/index.html.erb index d2962fba2..6e294d4e5 100644 --- a/app/views/admin/system_emails/index.html.erb +++ b/app/views/admin/system_emails/index.html.erb @@ -20,8 +20,6 @@ <%= link_to t("admin.shared.view"), admin_system_email_view_path(system_email), class: "button hollow" %> - <%= link_to t("admin.shared.preview"), admin_system_email_preview_path(system_email), - class: "button" %> <% end %> diff --git a/app/views/admin/system_emails/view.html.erb b/app/views/admin/system_emails/view.html.erb new file mode 100644 index 000000000..9aaeb5226 --- /dev/null +++ b/app/views/admin/system_emails/view.html.erb @@ -0,0 +1,36 @@ +<%= back_link_to admin_system_emails_path %> + +

<%= t("admin.system_emails.#{@system_email}.title") %>

+ +
+
+
+
+ <%= t("admin.newsletters.show.from") %>
+ <%= Setting['mailer_from_address'] %> +
+
+ <%= t("admin.newsletters.show.subject") %>
+ <%= @subject %> +
+
+
+ + <%= t("admin.newsletters.show.body") %> +

+ <%= t("admin.newsletters.show.body_help_text") %> +

+
+ <%= render file: "app/views/layouts/_mailer_header.html.erb" %> + + + + + <%= render file: "app/views/mailer/#{@system_email}.html.erb" %> + + +
+ + <%= render file: "app/views/layouts/_mailer_footer.html.erb" %> +
+
diff --git a/config/locales/en/seeds.yml b/config/locales/en/seeds.yml index a3587c9e3..4e40cfd63 100644 --- a/config/locales/en/seeds.yml +++ b/config/locales/en/seeds.yml @@ -53,18 +53,3 @@ en: recounting_poll: "Recounting Poll" expired_poll_without_stats: "Expired Poll without Stats & Results" expired_poll_with_stats: "Expired Poll with Stats & Results" - admin_notifications: - internal_link: - title: 'Do you have a proposal?' - body: 'Remember you can create a proposal with your ideas and people will discuss & support it.' - link: '/proposals' - external_link: - title: Help us translate consul - body: 'If you are proficient in a language, please help us translate consul!.' - link: 'https://crwd.in/consul' - without_link: - title: 'You can now geolocate proposals & investments' - body: 'When you create a proposal or investment you now can specify a point on a map' - not_sent: - title: 'We are closing the Participatory Budget!!' - body: 'Hurry up and create a last proposal before it ends next in few days!' diff --git a/config/locales/es/seeds.yml b/config/locales/es/seeds.yml index d8a40471b..1d6563bef 100644 --- a/config/locales/es/seeds.yml +++ b/config/locales/es/seeds.yml @@ -53,18 +53,3 @@ es: recounting_poll: "Votación en Recuento" expired_poll_without_stats: "Votación Finalizada (sin Estadísticas o Resultados)" expired_poll_with_stats: "Votación Finalizada (con Estadísticas y Resultado)" - admin_notifications: - internal_link: - title: 'Tienes una propuesta?' - body: 'Recuerda que puedes crear propuestas y los ciudadanos las debatirán y apoyarán.' - link: '/proposals' - external_link: - title: 'Ayúdanos a traducir CONSUL' - body: 'Si dominas un idioma, ayúdanos a completar su traducción en CONSUL.' - link: 'https://crwd.in/consul' - without_link: - title: 'Ahora puedes geolocalizar propuestas y proyectos de inversión' - body: 'Cuando crees una propuesta o proyecto de inversión podrás especificar su localización en el mapa' - not_sent: - title: 'Últimos días para crear proyectos de Presupuestos Participativos' - body: 'Quedan pocos dias para que se cierre el plazo de presentación de proyectos de inversión para los presupuestos participativos!' diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 7652ecefc..2fe805593 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -167,7 +167,6 @@ namespace :admin do resources :system_emails, only: [:index] do get :view - get :preview end resources :emails_download, only: :index do diff --git a/spec/features/admin/system_emails_spec.rb b/spec/features/admin/system_emails_spec.rb new file mode 100644 index 000000000..ddd812236 --- /dev/null +++ b/spec/features/admin/system_emails_spec.rb @@ -0,0 +1,43 @@ +require 'rails_helper' + +feature "System Emails" do + + background do + admin = create(:administrator) + login_as(admin.user) + end + + context "Index" do + scenario "Lists all system emails with correct actions" do + visit admin_system_emails_path + + within('#proposal_notification_digest') do + expect(page).to have_link('View') + end + end + end + + context "View" do + scenario "#proposal_notification_digest" do + proposal_a = create(:proposal, title: 'Proposal A') + proposal_b = create(:proposal, title: 'Proposal B') + proposal_notification_a = create(:proposal_notification, proposal: proposal_a, + title: 'Proposal A Title', + body: 'Proposal A Notification Body') + proposal_notification_b = create(:proposal_notification, proposal: proposal_b, + title: 'Proposal B Title', + body: 'Proposal B Notification Body') + notification_a = create(:notification, notifiable: proposal_notification_a) + notification_b = create(:notification, notifiable: proposal_notification_b) + + visit admin_system_email_view_path('proposal_notification_digest') + + expect(page).to have_content('Proposal notifications in') + expect(page).to have_link('Proposal A Title', href: notification_url(notification_a)) + expect(page).to have_link('Proposal B Title', href: notification_url(notification_b)) + expect(page).to have_content('Proposal A Notification Body') + expect(page).to have_content('Proposal B Notification Body') + end + end + +end