From f47ec9d7dcd24cd69a85d427990a2d451d49f2c2 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 26 Mar 2019 18:21:19 +0100 Subject: [PATCH] Fix hound warnings --- .../management/proposals_controller.rb | 12 +- app/controllers/polls_controller.rb | 8 +- app/models/administrator_task.rb | 2 +- app/models/community.rb | 2 +- app/models/dashboard/executed_action.rb | 4 +- app/models/poll.rb | 4 +- app/models/proposal.rb | 8 +- spec/features/admin/dashboard/actions_spec.rb | 64 +++++----- spec/features/dashboard/polls_spec.rb | 102 +++++++-------- .../proposal_dashboard_actions_helper_spec.rb | 16 +-- spec/mailers/dashboard/mailer_spec.rb | 120 +++++++++++++----- spec/shared/features/nested_documentable.rb | 6 +- 12 files changed, 203 insertions(+), 145 deletions(-) diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index 24d5c22d6..2c497299a 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -8,11 +8,12 @@ class Management::ProposalsController < Management::BaseController before_action :load_categories, only: [:new, :edit] before_action :load_geozones, only: [:edit] - has_orders %w{confidence_score hot_score created_at most_commented random}, only: [:index, :print] - has_orders %w{most_voted newest}, only: :show + has_orders %w[confidence_score hot_score created_at most_commented random], only: [:index, :print] + has_orders %w[most_voted newest], only: :show def create - @resource = resource_model.new(strong_params.merge(author: current_user, published_at: Time.now)) + @resource = resource_model.new(strong_params.merge(author: current_user, + published_at: Time.now)) if @resource.save track_event @@ -51,8 +52,9 @@ class Management::ProposalsController < Management::BaseController end def proposal_params - params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, - :responsible_name, :tag_list, :terms_of_service, :geozone_id, :skip_map, + params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, + :video_url, :responsible_name, :tag_list, :terms_of_service, + :geozone_id, :skip_map, map_location_attributes: [:latitude, :longitude, :zoom]) end diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 8bf987e9e..70f1c7030 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -6,18 +6,20 @@ class PollsController < ApplicationController load_and_authorize_resource has_filters %w[current expired] - has_orders %w{most_voted newest oldest}, only: :show + has_orders %w[most_voted newest oldest], only: :show ::Poll::Answer # trigger autoload def index - @polls = @polls.public_polls.send(@current_filter).includes(:geozones).sort_for_list.page(params[:page]) + @polls = @polls.public_polls.send(@current_filter).includes(:geozones) + .sort_for_list.page(params[:page]) end def show @questions = @poll.questions.for_render.sort_for_list @token = poll_voter_token(@poll, current_user) - @poll_questions_answers = Poll::Question::Answer.where(question: @poll.questions).where.not(description: "").order(:given_order) + @poll_questions_answers = Poll::Question::Answer.where(question: @poll.questions) + .where.not(description: "").order(:given_order) @answers_by_question_id = {} poll_answers = ::Poll::Answer.by_question(@poll.question_ids).by_author(current_user.try(:id)) diff --git a/app/models/administrator_task.rb b/app/models/administrator_task.rb index 026a524b4..64c59cfdc 100644 --- a/app/models/administrator_task.rb +++ b/app/models/administrator_task.rb @@ -7,5 +7,5 @@ class AdministratorTask < ActiveRecord::Base default_scope { order(created_at: :asc) } scope :pending, -> { where(executed_at: nil) } - scope :done, -> { where.not(executed_at: nil) } + scope :done, -> { where.not(executed_at: nil) } end diff --git a/app/models/community.rb b/app/models/community.rb index f1640c8e9..78bc2994f 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -16,7 +16,7 @@ class Community < ActiveRecord::Base def latest_activity activity = [] - + most_recent_comment = Comment.where(commentable: topics).order(updated_at: :desc).take(1).first activity << most_recent_comment.updated_at unless most_recent_comment.nil? diff --git a/app/models/dashboard/executed_action.rb b/app/models/dashboard/executed_action.rb index f41b2481d..c5a16c815 100644 --- a/app/models/dashboard/executed_action.rb +++ b/app/models/dashboard/executed_action.rb @@ -1,8 +1,8 @@ class Dashboard::ExecutedAction < ActiveRecord::Base belongs_to :proposal - belongs_to :action, class_name: 'Dashboard::Action' + belongs_to :action, class_name: "Dashboard::Action" - has_many :administrator_tasks, as: :source, dependent: :destroy, class_name: 'Dashboard::AdministratorTask' + has_many :administrator_tasks, as: :source, dependent: :destroy, class_name: "Dashboard::AdministratorTask" validates :proposal, presence: true, uniqueness: { scope: :action } validates :action, presence: true diff --git a/app/models/poll.rb b/app/models/poll.rb index debe1828d..826ab1f81 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -42,7 +42,7 @@ class Poll < ActiveRecord::Base scope :sort_for_list, -> { order(:geozone_restricted, :starts_at, :name) } def self.overlaping_with(poll) - where('? < ends_at and ? >= starts_at', poll.starts_at.beginning_of_day, poll.ends_at.end_of_day) + where("? < ends_at and ? >= starts_at", poll.starts_at.beginning_of_day, poll.ends_at.end_of_day) .where.not(id: poll.id) .where(related: poll.related) end @@ -122,7 +122,7 @@ class Poll < ActiveRecord::Base return unless starts_at.present? return unless ends_at.present? return unless Poll.overlaping_with(self).any? - errors.add(:starts_at, I18n.t('activerecord.errors.messages.another_poll_active')) + errors.add(:starts_at, I18n.t("activerecord.errors.messages.another_poll_active")) end def public? diff --git a/app/models/proposal.rb b/app/models/proposal.rb index e494fed09..6d6bdb230 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -27,14 +27,14 @@ class Proposal < ActiveRecord::Base acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases - RETIRE_OPTIONS = %w(duplicated started unfeasible done other) + RETIRE_OPTIONS = %w[duplicated started unfeasible done other] belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id" belongs_to :geozone has_many :comments, as: :commentable, dependent: :destroy has_many :proposal_notifications, dependent: :destroy - has_many :dashboard_executed_actions, dependent: :destroy, class_name: 'Dashboard::ExecutedAction' - has_many :dashboard_actions, through: :dashboard_executed_actions, class_name: 'Dashboard::Action' + has_many :dashboard_executed_actions, dependent: :destroy, class_name: "Dashboard::ExecutedAction" + has_many :dashboard_actions, through: :dashboard_executed_actions, class_name: "Dashboard::Action" has_many :polls, as: :related validates :title, presence: true @@ -228,7 +228,7 @@ class Proposal < ActiveRecord::Base end def self.proposals_orders(user) - orders = %w{hot_score confidence_score created_at relevance archival_date} + orders = %w[hot_score confidence_score created_at relevance archival_date] orders << "recommendations" if Setting["feature.user.recommendations_on_proposals"] && user&.recommended_proposals return orders end diff --git a/spec/features/admin/dashboard/actions_spec.rb b/spec/features/admin/dashboard/actions_spec.rb index 4462a32c9..26050ca6a 100644 --- a/spec/features/admin/dashboard/actions_spec.rb +++ b/spec/features/admin/dashboard/actions_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Admin dashboard actions' do +feature "Admin dashboard actions" do let(:admin) { create :administrator } before do @@ -16,99 +16,99 @@ feature 'Admin dashboard actions' do "Save", "Action created successfully" - context 'when visiting index' do - context 'and no actions defined' do + context "when visiting index" do + context "and no actions defined" do before do visit admin_dashboard_actions_path end - scenario 'shows that there are no records available' do - expect(page).to have_content('No records found') + scenario "shows that there are no records available" do + expect(page).to have_content("No records found") end end - context 'and actions defined' do + context "and actions defined" do let!(:action) { create :dashboard_action } before do visit admin_dashboard_actions_path end - scenario 'shows the action data' do + scenario "shows the action data" do expect(page).to have_content(action.title) end end end - context 'when creating an action' do + context "when creating an action" do let(:action) { build :dashboard_action } before do visit admin_dashboard_actions_path - click_link 'Create resource or action' + click_link "Create resource or action" end - scenario 'Creates a new action' do - fill_in 'dashboard_action_title', with: action.title - fill_in 'dashboard_action_description', with: action.description + scenario "Creates a new action" do + fill_in "dashboard_action_title", with: action.title + fill_in "dashboard_action_description", with: action.description - click_button 'Save' + click_button "Save" expect(page).to have_content(action.title) end - scenario 'Renders create form in case data is invalid' do - click_button 'Save' - expect(page).to have_content('errors prevented this Dashboard/Action from being saved.') + scenario "Renders create form in case data is invalid" do + click_button "Save" + expect(page).to have_content("errors prevented this Dashboard/Action from being saved.") end end - context 'when editing an action' do + context "when editing an action" do let!(:action) { create :dashboard_action } let(:title) { Faker::Lorem.sentence } before do visit admin_dashboard_actions_path - click_link 'Edit' + click_link "Edit" end - scenario 'Updates the action' do - fill_in 'dashboard_action_title', with: title - click_button 'Save' + scenario "Updates the action" do + fill_in "dashboard_action_title", with: title + click_button "Save" expect(page).to have_content(title) end - scenario 'Renders edit form in case data is invalid' do - fill_in 'dashboard_action_title', with: 'x' - click_button 'Save' - expect(page).to have_content('error prevented this Dashboard/Action from being saved.') + scenario "Renders edit form in case data is invalid" do + fill_in "dashboard_action_title", with: "x" + click_button "Save" + expect(page).to have_content("error prevented this Dashboard/Action from being saved.") end end - context 'when destroying an action' do + context "when destroying an action" do let!(:action) { create :dashboard_action } before do visit admin_dashboard_actions_path end - scenario 'deletes the action', js: true do + scenario "deletes the action", js: true do page.accept_confirm do - click_link 'Delete' + click_link "Delete" end expect(page).not_to have_content(action.title) end - scenario 'can not delete actions that have been executed', js: true do + scenario "can not delete actions that have been executed", js: true do _executed_action = create(:dashboard_executed_action, action: action) page.accept_confirm do - click_link 'Delete' + click_link "Delete" end - expect(page).to have_content('Cannot delete record because dependent executed actions exist') + expect(page).to have_content("Cannot delete record because dependent executed actions exist") end end end diff --git a/spec/features/dashboard/polls_spec.rb b/spec/features/dashboard/polls_spec.rb index add203101..85a4ae864 100644 --- a/spec/features/dashboard/polls_spec.rb +++ b/spec/features/dashboard/polls_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Polls' do +feature "Polls" do let!(:proposal) { create(:proposal, :draft) } before do @@ -8,99 +8,99 @@ feature 'Polls' do visit proposal_dashboard_path(proposal) end - scenario 'Has a link to polls feature' do - expect(page).to have_link('Polls') + scenario "Has a link to polls feature" do + expect(page).to have_link("Polls") end - scenario 'Create a poll', :js do - click_link 'Polls' - click_link 'Create poll' + scenario "Create a poll", :js do + click_link "Polls" + click_link "Create poll" start_date = 1.week.from_now end_date = 2.weeks.from_now - fill_in "poll_name", with: 'Upcoming poll' - fill_in 'poll_starts_at', with: start_date.strftime('%d/%m/%Y') - fill_in 'poll_ends_at', with: end_date.strftime('%d/%m/%Y') - fill_in 'poll_description', with: "Upcomming poll's description. This poll..." + fill_in "poll_name", with: "Proposal poll" + fill_in "poll_starts_at", with: start_date.strftime("%d/%m/%Y") + fill_in "poll_ends_at", with: end_date.strftime("%d/%m/%Y") + fill_in "poll_description", with: "Proposal's poll description. This poll..." - expect(page).not_to have_css('#poll_results_enabled') - expect(page).not_to have_css('#poll_stats_enabled') + expect(page).not_to have_css("#poll_results_enabled") + expect(page).not_to have_css("#poll_stats_enabled") - click_link 'Add question' + click_link "Add question" - fill_in 'Question', with: 'First question' + fill_in "Question", with: "First question" - click_link 'Add answer' - fill_in 'Title', with: 'First answer' + click_link "Add answer" - click_button 'Create poll' + fill_in "Answer", with: "First answer" - expect(page).to have_content 'Poll created successfully' - expect(page).to have_content 'Upcoming poll' + click_button "Create poll" + expect(page).to have_content "Poll created successfully" + expect(page).to have_content "Proposal poll" expect(page).to have_content I18n.l(start_date.to_date) end - scenario 'Create a poll redirects back to form when invalid data', js: true do - click_link 'Polls' - click_link 'Create poll' + scenario "Create a poll redirects back to form when invalid data", js: true do + click_link "Polls" + click_link "Create poll" - click_button 'Create poll' + click_button "Create poll" - expect(page).to have_content('New poll') + expect(page).to have_content("New poll") end - scenario 'Edit poll is allowed for upcoming polls' do poll = create(:poll, :incoming, related: proposal) + scenario "Edit poll is allowed for upcoming polls" do visit proposal_dashboard_polls_path(proposal) within "div#poll_#{poll.id}" do - expect(page).to have_content('Edit survey') + expect(page).to have_content("Edit survey") - click_link 'Edit survey' + click_link "Edit survey" end - click_button 'Update poll' + click_button "Update poll" - expect(page).to have_content 'Poll updated successfully' + expect(page).to have_content "Poll updated successfully" end - scenario 'Edit poll redirects back when invalid data', js: true do poll = create(:poll, :incoming, related: proposal) + scenario "Edit poll redirects back when invalid data", js: true do visit proposal_dashboard_polls_path(proposal) within "div#poll_#{poll.id}" do - expect(page).to have_content('Edit survey') + expect(page).to have_content("Edit survey") - click_link 'Edit survey' + click_link "Edit survey" end - fill_in "poll_name", with: '' + fill_in "poll_name", with: "" - click_button 'Update poll' + click_button "Update poll" - expect(page).to have_content('Edit poll') + expect(page).to have_content("Edit poll") end - scenario 'Edit poll is not allowed for current polls' do + scenario "Edit poll is not allowed for current polls" do poll = create(:poll, :current, related: proposal) visit proposal_dashboard_polls_path(proposal) within "div#poll_#{poll.id}" do - expect(page).not_to have_content('Edit survey') + expect(page).not_to have_content("Edit survey") end end - scenario 'Edit poll is not allowed for expired polls' do + scenario "Edit poll is not allowed for expired polls" do poll = create(:poll, :expired, related: proposal) visit proposal_dashboard_polls_path(proposal) within "div#poll_#{poll.id}" do - expect(page).not_to have_content('Edit survey') + expect(page).not_to have_content("Edit survey") end end @@ -153,52 +153,52 @@ feature 'Polls' do end end - scenario 'View results not available for upcoming polls' do poll = create(:poll, :incoming, related: proposal) + scenario "View results not available for upcoming polls" do visit proposal_dashboard_polls_path(proposal) within "div#poll_#{poll.id}" do - expect(page).not_to have_content('View results') + expect(page).not_to have_content("View results") end end - scenario 'View results available for current polls' do + scenario "View results available for current polls" do poll = create(:poll, :current, related: proposal) visit proposal_dashboard_polls_path(proposal) within "div#poll_#{poll.id}" do - expect(page).to have_content('View results') + expect(page).to have_content("View results") end end - scenario 'View results available for expired polls' do + scenario "View results available for expired polls" do poll = create(:poll, :expired, related: proposal) visit proposal_dashboard_polls_path(proposal) within "div#poll_#{poll.id}" do - expect(page).to have_content('View results') + expect(page).to have_content("View results") end end - scenario 'View results redirects to results in public zone', js: true do + scenario "View results redirects to results in public zone", js: true do poll = create(:poll, :expired, related: proposal) visit proposal_dashboard_polls_path(proposal) within "div#poll_#{poll.id}" do - click_link 'View results' + click_link "View results" end page.driver.browser.switch_to.window page.driver.browser.window_handles.last do - expect(page.current_path).to eq(results_poll_path(poll)) + expect(page).to have_current_path(results_poll_path(poll)) end end - scenario 'Poll card' do - poll = create(:poll, :expired, related: proposal) + scenario "Poll card" do + poll = create(:poll, :expired, related: proposal) visit proposal_dashboard_polls_path(proposal) diff --git a/spec/helpers/admin/proposal_dashboard_actions_helper_spec.rb b/spec/helpers/admin/proposal_dashboard_actions_helper_spec.rb index 63f7e31c4..4e4090e33 100644 --- a/spec/helpers/admin/proposal_dashboard_actions_helper_spec.rb +++ b/spec/helpers/admin/proposal_dashboard_actions_helper_spec.rb @@ -1,16 +1,16 @@ -require 'rails_helper' +require "rails_helper" describe Admin::ProposalDashboardActionsHelper do - describe 'active_human_readable' do - context 'when active is true' do - it 'returns label for active state' do - expect(active_human_readable(true)).to eq(t('admin.dashboard.actions.index.active')) + describe "active_human_readable" do + context "when active is true" do + it "returns label for active state" do + expect(active_human_readable(true)).to eq(t("admin.dashboard.actions.index.active")) end end - context 'when active is false' do - it 'returns label for inactive state' do - expect(active_human_readable(false)).to eq(t('admin.dashboard.actions.index.inactive')) + context "when active is false" do + it "returns label for inactive state" do + expect(active_human_readable(false)).to eq(t("admin.dashboard.actions.index.inactive")) end end end diff --git a/spec/mailers/dashboard/mailer_spec.rb b/spec/mailers/dashboard/mailer_spec.rb index 3f43be4b2..6afbfb291 100644 --- a/spec/mailers/dashboard/mailer_spec.rb +++ b/spec/mailers/dashboard/mailer_spec.rb @@ -34,18 +34,25 @@ describe Dashboard::Mailer do expect(email).to deliver_from("CONSUL ") expect(email).to deliver_to(proposal.author) - expect(email).to have_subject("More news about your citizen proposal in Decide Madrid") + expect(email).to have_subject("More news about your citizen proposal") expect(email).to have_body_text("Hello #{proposal.author.name},") - expect(email).to have_body_text("As you know, on the #{proposal.created_at.day} day of the #{proposal.created_at.strftime("%B")} you created the proposal in draft mode #{proposal.title} on the Decide Madrid platform.") + expect(email).to have_body_text("As you know, on the #{proposal.created_at.day} day of "\ + "the #{proposal.created_at.strftime("%B")} you created "\ + "the proposal in draft mode #{proposal.title}.") expect(email).to have_body_text("Whenever you want you can publish on this link:") - expect(email).to have_body_text("Seize this moment! Learn, add other people with the same interests and prepare the diffusion that you will need when you publish your proposal definitively.") - expect(email).to have_body_text("And to accompany you in this challenge, here are the news...") + expect(email).to have_body_text("Seize this moment! Learn, add other people with the same "\ + "interests and prepare the diffusion that you will need "\ + "when you publish your proposal definitively.") + expect(email).to have_body_text("And to accompany you in this challenge, "\ + "here are the news...") expect(email).to have_body_text("NEW UNLOCKED RESOURCE") expect(email).to have_body_text("#{resource.title}") expect(email).to have_body_text("Take a look at this NEW recommended ACTION:") expect(email).to have_body_text("#{action.title}") expect(email).to have_body_text("#{action.description}") - expect(email).to have_body_text("As always, enter the Proposals Panel and we will tell you in detail how to use these resources and how to get the most out of it.") + expect(email).to have_body_text("As always, enter the Proposals Panel and we will tell "\ + "you in detail how to use these resources and how to get "\ + "the most out of it.") expect(email).to have_body_text("Go ahead, discover them!") end end @@ -60,20 +67,30 @@ describe Dashboard::Mailer do expect(email).to deliver_from("CONSUL ") expect(email).to deliver_to(proposal.author) - expect(email).to have_subject("More news about your citizen proposal in Decide Madrid") + expect(email).to have_subject("More news about your citizen proposal") expect(email).to have_body_text("Hello #{proposal.author.name},") - expect(email).to have_body_text("As you know, on the #{proposal.published_at.day} day of the #{proposal.published_at.strftime("%B")} you published the proposal #{proposal.title} on the Decide Madrid platform.") - expect(email).to have_body_text("And so, you have a new resource available to help you keep moving forward.") + expect(email).to have_body_text("As you know, on the #{proposal.published_at.day} day of "\ + "the #{proposal.published_at.strftime("%B")} you "\ + "published the proposal #{proposal.title}.") + expect(email).to have_body_text("And so, you have a new resource available to help "\ + "you keep moving forward.") expect(email).to have_body_text("NEW UNLOCKED RESOURCE") expect(email).to have_body_text("#{resource.title}") - limit_to_archive_proposal = proposal.created_at.to_date + Setting["months_to_archive_proposals"].to_i.months + months_to_archive_proposals = Setting["months_to_archive_proposals"].to_i.months + limit_to_archive_proposal = proposal.created_at.to_date + months_to_archive_proposals days_count = (limit_to_archive_proposal - Date.today).to_i - expect(email).to have_body_text("You are missing #{days_count} days before your proposal gets the #{Setting["votes_for_proposal_success"]} supports and goes to referendum. Cheer up and keep spreading. Are you short of ideas?") + + expect(email).to have_body_text("You are missing #{days_count} days before your proposal "\ + "gets the #{Setting["votes_for_proposal_success"]} "\ + "supports and goes to referendum. Cheer up and keep "\ + "spreading. Are you short of ideas?") expect(email).to have_body_text("NEW RECOMMENDED DIFFUSION ACTION") expect(email).to have_body_text("#{action.title}") expect(email).to have_body_text("#{action.description}") - expect(email).to have_body_text("As always, enter the Proposals Panel and we will tell you in detail how to use these resources and how to get the most out of it.") + expect(email).to have_body_text("As always, enter the Proposals Panel and we will tell "\ + "you in detail how to use these resources and how to get "\ + "the most out of it.") expect(email).to have_body_text("Go ahead, discover them!") end end @@ -96,19 +113,39 @@ describe Dashboard::Mailer do expect(email).to deliver_from("CONSUL ") expect(email).to deliver_to(proposal.author) - expect(email).to have_subject("Your draft citizen proposal in Decide Madrid is created") + expect(email).to have_subject("Your draft citizen proposal is created") expect(email).to have_body_text("Hi #{proposal.author.name}!") - expect(email).to have_body_text("Your #{proposal.title} proposal has been successfully created.") - expect(email).to have_body_text("Take advantage that your proposal is not public yet and get ready to contact a lot of people.") - expect(email).to have_body_text(I18n.t("mailers.new_actions_notification_on_create.text_2", link: proposal_dashboard_url(proposal)).html_safe) - expect(email).to have_body_text("We know that creating a proposal with a hook and getting the necessary support can seem complicated. But dont worry because we are going to help you!") - expect(email).to have_body_text("You have a tool that will be your new best ally: The Citizen Proposals panel.") - expect(email).to have_body_text("Enter every day in the panel of your proposal to use the tips and resources that we will share with you.") - expect(email).to have_body_text("These tips, actions and resources will give you ideas and also practical solutions to get more support and a wider community. Dont forget them!") - expect(email).to have_body_text("As you gain more support, you will unlock new and better resources. At the moment, you have an e-mail template to send massively to all your contacts, a poster to print, among other features and rewards that you will discover. Dont stop adding support and we will not stop rewarding and helping you!") - expect(email).to have_body_text("You have #{Setting['months_to_archive_proposals']} months since you publish the proposal to get #{Setting['votes_for_proposal_success']} support and your proposal can become a reality. But the first days are the most important. It is a challenge. Get ready!") + expect(email).to have_body_text("Your #{proposal.title} proposal has been "\ + "successfully created.") + expect(email).to have_body_text("Take advantage that your proposal is not public yet and "\ + "get ready to contact a lot of people.") + expect(email).to have_body_text(I18n.t("mailers.new_actions_notification_on_create.text_2", + link: proposal_dashboard_url(proposal)).html_safe) + expect(email).to have_body_text("We know that creating a proposal with a hook and getting "\ + "the necessary support can seem complicated. But dont "\ + "worry because we are going to help you!") + expect(email).to have_body_text("You have a tool that will be your new best ally: "\ + "The Citizen Proposals panel.") + expect(email).to have_body_text("Enter every day in the panel of your proposal to use the "\ + "tips and resources that we will share with you.") + expect(email).to have_body_text("These tips, actions and resources will give you ideas and "\ + "also practical solutions to get more support and a wider "\ + "community. Dont forget them!") + expect(email).to have_body_text("As you gain more support, you will unlock new and better "\ + "resources. At the moment, you have an e-mail template to "\ + "send massively to all your contacts, a poster to print, "\ + "among other features and rewards that you will discover. "\ + "Dont stop adding support and we will not stop rewarding "\ + "and helping you!") + expect(email).to have_body_text("You have #{Setting['months_to_archive_proposals']} months "\ + "since you publish the proposal to get "\ + "#{Setting['votes_for_proposal_success']} support and your "\ + "proposal can become a reality. But the first days are the "\ + "most important. It is a challenge. Get ready!") expect(email).to have_body_text("And for you to start with all the motivation,") - expect(email).to have_body_text("here you have several resources and a whole list of tips that will come to you every day to prepare the broadcast!") + expect(email).to have_body_text("here you have several resources and a whole list of "\ + "tips that will come to you every day to prepare the "\ + "broadcast!") expect(email).to have_body_text("Go ahead, discover them!") end end @@ -120,8 +157,10 @@ describe Dashboard::Mailer do end let!(:proposal) { build(:proposal, :draft) } - let!(:resource) { create(:dashboard_action, :resource, :active, day_offset: 0, published_proposal: true) } - let!(:proposed_action) { create(:dashboard_action, :proposed_action, :active, day_offset: 0, published_proposal: true) } + let!(:resource) { create(:dashboard_action, :resource, :active, day_offset: 0, + published_proposal: true) } + let!(:proposed_action) { create(:dashboard_action, :proposed_action, :active, day_offset: 0, + published_proposal: true) } it "sends emails when detect new actions when publish a proposal" do proposal.save @@ -131,19 +170,34 @@ describe Dashboard::Mailer do expect(email).to deliver_from("CONSUL ") expect(email).to deliver_to(proposal.author) - expect(email).to have_subject("Your citizen proposal is already published Dont stop spreading!") - expect(email).to have_body_text("Congratulations #{proposal.author.name}! Your proposal #{proposal.title} has been created successfully.") + expect(email).to have_subject("Your citizen proposal is already "\ + "published Dont stop spreading!") + expect(email).to have_body_text("Congratulations #{proposal.author.name}! Your proposal "\ + "#{proposal.title} has been created successfully.") expect(email).to have_body_text("And now, go for your first 100 supports!") expect(email).to have_body_text("Why 100?") - expect(email).to have_body_text("Our experience tells us that the first day is fundamental. Because in addition to having the energy to launch something new, being a newly published proposal, you will have the important visibility of being among the new proposals highlighted in Decide Madrid.") - expect(email).to have_body_text("Get 100 supports on the first day, and you will have a first community to back you up.") - expect(email).to have_body_text("That is why we challenge you to get it, but not without a lot of help!") - expect(email).to have_body_text("Remember that in your Proposal Panel you have new resources available and recommendations for dissemination actions.") - expect(email).to have_body_text("Come in every day to see your progress and use the tips and resources we will share with you. They are ideas and also practical solutions to get the support you need.") - expect(email).to have_body_text("As you get more support, you will unlock new and better resources. Do not stop adding support and we will not stop rewarding and helping you!") + expect(email).to have_body_text("Our experience tells us that the first day is fundamental. "\ + "Because in addition to having the energy to launch "\ + "something new, being a newly published proposal, you will "\ + "have the important visibility of being among the new "\ + "proposals highlighted.") + expect(email).to have_body_text("Get 100 supports on the first day, and you will have "\ + "a first community to back you up.") + expect(email).to have_body_text("That is why we challenge you to get it, but not without "\ + "a lot of help!") + expect(email).to have_body_text("Remember that in your Proposal Panel you have new "\ + "resources available and recommendations for "\ + "dissemination actions.") + expect(email).to have_body_text("Come in every day to see your progress and use the tips "\ + "and resources we will share with you. They are ideas and "\ + "also practical solutions to get the support you need.") + expect(email).to have_body_text("As you get more support, you will unlock new and better "\ + "resources. Do not stop adding support and we will not stop "\ + "rewarding and helping you!") expect(email).to have_body_text("And for you to start at full speed...") expect(email).to have_body_text("Here is a great resource at your disposal!") - expect(email).to have_body_text("You will also find this new recommended dissemination action...") + expect(email).to have_body_text("You will also find this new recommended dissemination "\ + "action...") expect(email).to have_body_text("You sure have more resources to use!") expect(email).to have_body_text("Go ahead, discover them!") end diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index 1bf0b806d..8c33d8763 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -137,7 +137,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na visit send(path, arguments) documentable_attach_new_file( - Rails.root.join("spec/fixtures/files/logo_header.png"), + Rails.root.join("spec/fixtures/files/logo_header.gif"), false ) @@ -158,7 +158,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na visit send(path, arguments) documentable_attach_new_file( - Rails.root.join("spec/fixtures/files/logo_header.png"), + Rails.root.join("spec/fixtures/files/logo_header.gif"), false ) @@ -239,7 +239,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end login_as user_to_login visit send(path, arguments) - FILENAMES ||= %w(clippy empty logo).freeze + FILENAMES ||= %w[clippy empty logo].freeze send(fill_resource_method_name) if fill_resource_method_name