diff --git a/spec/system/advanced_search_spec.rb b/spec/system/advanced_search_spec.rb index 27d281c10..8eefdbec3 100644 --- a/spec/system/advanced_search_spec.rb +++ b/spec/system/advanced_search_spec.rb @@ -66,6 +66,7 @@ describe "Advanced search" do context "Search by author type" do scenario "Public employee" do + Setting["official_level_1_name"] = "Official position 1" ana = create :user, official_level: 1 john = create :user, official_level: 2 @@ -76,7 +77,7 @@ describe "Advanced search" do visit debates_path click_link "Advanced search" - select Setting["official_level_1_name"], from: "advanced_search_official_level" + select "Official position 1", from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 debates") @@ -89,6 +90,7 @@ describe "Advanced search" do end scenario "Municipal Organization" do + Setting["official_level_2_name"] = "Official position 2" ana = create :user, official_level: 2 john = create :user, official_level: 3 @@ -99,7 +101,7 @@ describe "Advanced search" do visit proposals_path click_link "Advanced search" - select Setting["official_level_2_name"], from: "advanced_search_official_level" + select "Official position 2", from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 citizen proposals") @@ -112,6 +114,7 @@ describe "Advanced search" do end scenario "General director" do + Setting["official_level_3_name"] = "Official position 3" ana = create :user, official_level: 3 john = create :user, official_level: 4 @@ -122,7 +125,7 @@ describe "Advanced search" do visit budget_investments_path(budget) click_link "Advanced search" - select Setting["official_level_3_name"], from: "advanced_search_official_level" + select "Official position 3", from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 investments") @@ -135,6 +138,7 @@ describe "Advanced search" do end scenario "City councillor" do + Setting["official_level_4_name"] = "Official position 4" ana = create :user, official_level: 4 john = create :user, official_level: 5 @@ -145,7 +149,7 @@ describe "Advanced search" do visit debates_path click_link "Advanced search" - select Setting["official_level_4_name"], from: "advanced_search_official_level" + select "Official position 4", from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 debates") @@ -158,6 +162,7 @@ describe "Advanced search" do end scenario "Mayoress" do + Setting["official_level_5_name"] = "Official position 5" ana = create :user, official_level: 5 john = create :user, official_level: 4 @@ -168,7 +173,7 @@ describe "Advanced search" do visit proposals_path click_link "Advanced search" - select Setting["official_level_5_name"], from: "advanced_search_official_level" + select "Official position 5", from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 citizen proposals") @@ -310,6 +315,7 @@ describe "Advanced search" do end scenario "Search by multiple filters" do + Setting["official_level_1_name"] = "Official position 1" ana = create :user, official_level: 1 john = create :user, official_level: 1 @@ -321,7 +327,7 @@ describe "Advanced search" do click_link "Advanced search" fill_in "Write the text", with: "Schwifty" - select Setting["official_level_1_name"], from: "advanced_search_official_level" + select "Official position 1", from: "advanced_search_official_level" select "Last 24 hours", from: "js-advanced-search-date-min" click_button "Filter" @@ -334,18 +340,20 @@ describe "Advanced search" do end scenario "Maintain advanced search criteria" do + Setting["official_level_1_name"] = "Official position 1" + visit debates_path click_link "Advanced search" fill_in "Write the text", with: "Schwifty" - select Setting["official_level_1_name"], from: "advanced_search_official_level" + select "Official position 1", from: "advanced_search_official_level" select "Last 24 hours", from: "js-advanced-search-date-min" click_button "Filter" within "#js-advanced-search" do expect(page).to have_selector("input[name='search'][value='Schwifty']") - expect(page).to have_select("advanced_search[official_level]", selected: Setting["official_level_1_name"]) + expect(page).to have_select("advanced_search[official_level]", selected: "Official position 1") expect(page).to have_select("advanced_search[date_min]", selected: "Last 24 hours") end end diff --git a/spec/system/comments/budget_investments_spec.rb b/spec/system/comments/budget_investments_spec.rb index e5539b0bf..4f21b45eb 100644 --- a/spec/system/comments/budget_investments_spec.rb +++ b/spec/system/comments/budget_investments_spec.rb @@ -7,7 +7,7 @@ describe "Commenting Budget::Investments" do it_behaves_like "flaggable", :budget_investment_comment scenario "Index" do - 3.times { create(:comment, commentable: investment) } + not_valuations = 3.times.map { create(:comment, commentable: investment) } create(:comment, :valuation, commentable: investment, subject: "Not viable") visit budget_investment_path(investment.budget, investment) @@ -16,7 +16,7 @@ describe "Commenting Budget::Investments" do expect(page).not_to have_content("Not viable") within("#comments") do - Comment.not_valuations.last(3).each do |comment| + not_valuations.each do |comment| expect(page).to have_content comment.user.name expect(page).to have_content I18n.l(comment.created_at, format: :datetime) expect(page).to have_content comment.body diff --git a/spec/system/comments/debates_spec.rb b/spec/system/comments/debates_spec.rb index 11da98330..1b99f287f 100644 --- a/spec/system/comments/debates_spec.rb +++ b/spec/system/comments/debates_spec.rb @@ -8,12 +8,12 @@ describe "Commenting debates" do scenario "Index" do 3.times { create(:comment, commentable: debate) } + comment = Comment.includes(:user).last visit debate_path(debate) expect(page).to have_css(".comment", count: 3) - comment = Comment.last within first(".comment") do expect(page).to have_content comment.user.name expect(page).to have_content I18n.l(comment.created_at, format: :datetime) diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 4fe6f90e2..0e8c04ec2 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -8,6 +8,7 @@ describe "Commenting legislation questions" do scenario "Index" do 3.times { create(:comment, commentable: legislation_annotation) } + comment = Comment.includes(:user).last visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, @@ -15,7 +16,6 @@ describe "Commenting legislation questions" do expect(page).to have_css(".comment", count: 4) - comment = Comment.last within first(".comment") do expect(page).to have_content comment.user.name expect(page).to have_content I18n.l(comment.created_at, format: :datetime) diff --git a/spec/system/comments/legislation_questions_spec.rb b/spec/system/comments/legislation_questions_spec.rb index 3866376d3..76b48573a 100644 --- a/spec/system/comments/legislation_questions_spec.rb +++ b/spec/system/comments/legislation_questions_spec.rb @@ -12,12 +12,12 @@ describe "Commenting legislation questions" do scenario "Index" do 3.times { create(:comment, commentable: legislation_question) } + comment = Comment.includes(:user).last visit legislation_process_question_path(legislation_question.process, legislation_question) expect(page).to have_css(".comment", count: 3) - comment = Comment.last within first(".comment") do expect(page).to have_content comment.user.name expect(page).to have_content I18n.l(comment.created_at, format: :datetime) diff --git a/spec/system/comments/polls_spec.rb b/spec/system/comments/polls_spec.rb index 3eb4c94f1..32fa4724b 100644 --- a/spec/system/comments/polls_spec.rb +++ b/spec/system/comments/polls_spec.rb @@ -6,12 +6,12 @@ describe "Commenting polls" do scenario "Index" do 3.times { create(:comment, commentable: poll) } + comment = Comment.includes(:user).last visit poll_path(poll) expect(page).to have_css(".comment", count: 3) - comment = Comment.last within first(".comment") do expect(page).to have_content comment.user.name expect(page).to have_content I18n.l(comment.created_at, format: :datetime) diff --git a/spec/system/comments/proposals_spec.rb b/spec/system/comments/proposals_spec.rb index 29805c4ed..3348195b7 100644 --- a/spec/system/comments/proposals_spec.rb +++ b/spec/system/comments/proposals_spec.rb @@ -8,12 +8,12 @@ describe "Commenting proposals" do scenario "Index" do 3.times { create(:comment, commentable: proposal) } + comment = Comment.includes(:user).last visit proposal_path(proposal) expect(page).to have_css(".comment", count: 3) - comment = Comment.last within first(".comment") do expect(page).to have_content comment.user.name expect(page).to have_content I18n.l(comment.created_at, format: :datetime) diff --git a/spec/system/comments/topics_spec.rb b/spec/system/comments/topics_spec.rb index c4a021c7f..1b4483fc7 100644 --- a/spec/system/comments/topics_spec.rb +++ b/spec/system/comments/topics_spec.rb @@ -10,12 +10,12 @@ describe "Commenting topics from proposals" do community = proposal.community topic = create(:topic, community: community) create_list(:comment, 3, commentable: topic) + comment = Comment.includes(:user).last visit community_topic_path(community, topic) expect(page).to have_css(".comment", count: 3) - comment = Comment.last within first(".comment") do expect(page).to have_content comment.user.name expect(page).to have_content I18n.l(comment.created_at, format: :datetime) @@ -574,12 +574,12 @@ describe "Commenting topics from budget investments" do community = investment.community topic = create(:topic, community: community) create_list(:comment, 3, commentable: topic) + comment = Comment.includes(:user).last visit community_topic_path(community, topic) expect(page).to have_css(".comment", count: 3) - comment = Comment.last within first(".comment") do expect(page).to have_content comment.user.name expect(page).to have_content I18n.l(comment.created_at, format: :datetime) diff --git a/spec/system/tags/budget_investments_spec.rb b/spec/system/tags/budget_investments_spec.rb index 4acf353ae..1eb6f3744 100644 --- a/spec/system/tags/budget_investments_spec.rb +++ b/spec/system/tags/budget_investments_spec.rb @@ -94,8 +94,9 @@ describe "Tags" do click_button "Create Investment" expect(page).to have_content "Investment created successfully." + expect(page).to have_content "Build a skyscraper" - within "#tags_budget_investment_#{Budget::Investment.last.id}" do + within ".tags" do expect(page).to have_content tag_economia.name expect(page).not_to have_content tag_medio_ambiente.name end @@ -118,8 +119,9 @@ describe "Tags" do click_button "Create Investment" expect(page).to have_content "Investment created successfully." + expect(page).to have_content "Build a skyscraper" - within "#tags_budget_investment_#{Budget::Investment.last.id}" do + within ".tags" do expect(page).to have_content "Education" expect(page).not_to have_content "Health" end @@ -142,8 +144,9 @@ describe "Tags" do click_button "Create Investment" expect(page).to have_content "Investment created successfully." + expect(page).to have_content "Build a skyscraper" - within "#tags_budget_investment_#{Budget::Investment.last.id}" do + within ".tags" do expect(page).to have_content "Education" expect(page).not_to have_content "Health" end