diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6539113fa..a3ecc187d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -34,7 +34,7 @@ end Capybara.register_driver :headless_chrome do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( "goog:chromeOptions" => { - args: %W[headless no-sandbox window-size=1200,800 proxy-server=127.0.0.1:#{Capybara::Webmock.port_number}] + args: %W[headless no-sandbox window-size=1200,800 proxy-server=#{Capybara.app_host}:#{Capybara::Webmock.port_number}] } ) diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 6702b6609..68542dbf5 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -15,6 +15,10 @@ module CommonActions include Verifications include Votes + def app_host + "#{Capybara.app_host}:#{Capybara::Server.ports.values.last}" + end + def fill_in_signup_form(email = "manuela@consul.dev", password = "judgementday") fill_in "user_username", with: "Manuela Carmena #{rand(99999)}" fill_in "user_email", with: email diff --git a/spec/system/admin/system_emails_spec.rb b/spec/system/admin/system_emails_spec.rb index 13f73130d..37c56e386 100644 --- a/spec/system/admin/system_emails_spec.rb +++ b/spec/system/admin/system_emails_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -describe "System Emails" do +describe "System Emails", :js do let(:admin) { create(:administrator) } before do @@ -84,10 +84,10 @@ describe "System Emails" do 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: proposal_url(proposal_a, - anchor: "tab-notifications")) - expect(page).to have_link("Proposal B Title", href: proposal_url(proposal_b, - anchor: "tab-notifications")) + expect(page).to have_link("Proposal A Title", + href: proposal_url(proposal_a, anchor: "tab-notifications", host: app_host)) + expect(page).to have_link("Proposal B Title", + href: proposal_url(proposal_b, anchor: "tab-notifications", host: app_host)) expect(page).to have_content("Proposal A Notification Body") expect(page).to have_content("Proposal B Notification Body") end @@ -102,9 +102,9 @@ describe "System Emails" do expect(page).to have_content "Cleaner city" expect(page).to have_content "Budget for 2019" - expect(page).to have_link "Participatory Budgets", href: budgets_url + expect(page).to have_link "Participatory Budgets", href: budgets_url(host: app_host) - share_url = budget_investment_url(budget, investment, anchor: "social-share") + share_url = budget_investment_url(budget, investment, anchor: "social-share", host: app_host) expect(page).to have_link "Share your project", href: share_url end @@ -116,7 +116,7 @@ describe "System Emails" do expect(page).to have_content "Your investment project '#{investment.code}' has been selected" expect(page).to have_content "Start to get votes, share your investment project" - share_url = budget_investment_url(budget, investment, anchor: "social-share") + share_url = budget_investment_url(budget, investment, anchor: "social-share", host: app_host) expect(page).to have_link "Share your investment project", href: share_url end @@ -152,7 +152,7 @@ describe "System Emails" do expect(page).to have_content "There is a new comment from #{commenter.name}" expect(page).to have_content comment.body - expect(page).to have_link "Let's do...", href: debate_url(debate) + expect(page).to have_link "Let's do...", href: debate_url(debate, host: app_host) end scenario "#reply" do @@ -169,7 +169,7 @@ describe "System Emails" do expect(page).to have_content "There is a new response from #{replier.name}" expect(page).to have_content reply.body - expect(page).to have_link "Let's do...", href: comment_url(reply) + expect(page).to have_link "Let's do...", href: comment_url(reply, host: app_host) end scenario "#direct_message_for_receiver" do @@ -179,7 +179,7 @@ describe "System Emails" do expect(page).to have_content "Message's Title" expect(page).to have_content "This is a sample of message's content." - expect(page).to have_link "Reply to #{admin.user.name}", href: user_url(admin.user) + expect(page).to have_link "Reply to #{admin.user.name}", href: user_url(admin.user, host: app_host) end scenario "#direct_message_for_sender" do @@ -197,7 +197,7 @@ describe "System Emails" do expect(page).to have_content "Confirm your account using the following link" - expect(page).to have_link "this link", href: email_url(email_verification_token: "abc") + expect(page).to have_link "this link", href: email_url(email_verification_token: "abc", host: app_host) end scenario "#user_invite" do @@ -257,7 +257,7 @@ describe "System Emails" do expect(page).to have_content comment.body expect(page).to have_link "Cleaner city", - href: admin_budget_budget_investment_url(investment.budget, investment, anchor: "comments") + href: admin_budget_budget_investment_url(investment.budget, investment, anchor: "comments", host: app_host) end end @@ -277,12 +277,12 @@ describe "System Emails" do visit admin_system_email_preview_pending_path("proposal_notification_digest") expect(page).to have_content("This is the content pending to be sent") - expect(page).to have_link("Proposal A", href: proposal_url(proposal_a)) - expect(page).to have_link("Proposal B", href: proposal_url(proposal_b)) - expect(page).to have_link("Proposal A Title", href: proposal_url(proposal_a, - anchor: "tab-notifications")) - expect(page).to have_link("Proposal B Title", href: proposal_url(proposal_b, - anchor: "tab-notifications")) + expect(page).to have_link("Proposal A", href: proposal_url(proposal_a, host: app_host)) + expect(page).to have_link("Proposal B", href: proposal_url(proposal_b, host: app_host)) + expect(page).to have_link("Proposal A Title", + href: proposal_url(proposal_a, anchor: "tab-notifications", host: app_host)) + expect(page).to have_link("Proposal B Title", + href: proposal_url(proposal_b, anchor: "tab-notifications", host: app_host)) end scenario "#moderate_pending" do diff --git a/spec/system/social_media_meta_tags_spec.rb b/spec/system/social_media_meta_tags_spec.rb index 448776b9d..275f0ff59 100644 --- a/spec/system/social_media_meta_tags_spec.rb +++ b/spec/system/social_media_meta_tags_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -describe "Social media meta tags" do +describe "Social media meta tags", :js do context "Setting social media meta tags" do let(:meta_keywords) { "citizen, participation, open government" } let(:meta_title) { "CONSUL" } @@ -28,14 +28,12 @@ describe "Social media meta tags" do expect(page).to have_meta "twitter:site", with: twitter_handle expect(page).to have_meta "twitter:title", with: meta_title expect(page).to have_meta "twitter:description", with: meta_description - expect(page).to have_meta "twitter:image", - with: "#{Capybara.app_host}/social_media_icon_twitter.png" - + expect(page).to have_meta "twitter:image", with: "#{app_host}/social_media_icon_twitter.png" expect(page).to have_property "og:title", with: meta_title expect(page).to have_property "article:publisher", with: url expect(page).to have_property "article:author", with: "https://www.facebook.com/#{facebook_handle}" - expect(page).to have_property "og:url", with: "#{Capybara.app_host}/" - expect(page).to have_property "og:image", with: "#{Capybara.app_host}/social_media_icon.png" + expect(page).to have_property "og:url", with: "#{app_host}/" + expect(page).to have_property "og:image", with: "#{app_host}/social_media_icon.png" expect(page).to have_property "og:site_name", with: org_name expect(page).to have_property "og:description", with: meta_description end