diff --git a/spec/lib/overrides_spec.rb b/spec/lib/overrides_spec.rb new file mode 100644 index 0000000..d5f95c8 --- /dev/null +++ b/spec/lib/overrides_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require "rails_helper" + +# We make sure that the checksum of the file overridden is the same +# as the expected. If this test fails, it means that the overridden +# file should be updated to match any change/bug fix introduced in the core +checksums = [ + { + package: "decidim-core", + files: { + # views + "/app/views/layouts/decidim/footer/_mini.html.erb" => "cf7e273390b5a94b7df7167e37038ec4" + } + } +] + +describe "Overridden files", type: :view do + checksums.each do |item| + spec = Gem::Specification.find_by_name(item[:package]) + item[:files].each do |file, signature| + next unless spec + + it "#{spec.gem_dir}#{file} matches checksum" do + expect(md5("#{spec.gem_dir}#{file}")).to eq(signature) + end + end + end + + private + + def md5(file) + Digest::MD5.hexdigest(File.read(file)) + end +end diff --git a/spec/shared/visiting_organization_homepage.rb b/spec/shared/visiting_organization_homepage.rb new file mode 100644 index 0000000..7d980be --- /dev/null +++ b/spec/shared/visiting_organization_homepage.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +shared_context "when visiting organization homepage" do + let(:organization) { create(:organization) } + + before do + switch_to_host(organization.host) + visit decidim.root_path + end +end diff --git a/spec/system/eu_footer_spec.rb b/spec/system/eu_footer_spec.rb new file mode 100644 index 0000000..11b4c74 --- /dev/null +++ b/spec/system/eu_footer_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe "Has EU footer", perform_enqueued: true do + include_context "when visiting organization homepage" + + it "renders the eu flag in the footer" do + expect(page).to have_xpath("//img[@alt='European Union flag: Funded by the European Union']") + end +end diff --git a/spec/system/homepage_spec.rb b/spec/system/homepage_spec.rb index 80a86f7..3ec4c1b 100644 --- a/spec/system/homepage_spec.rb +++ b/spec/system/homepage_spec.rb @@ -3,12 +3,7 @@ require "rails_helper" describe "Visit the home page", perform_enqueued: true do - let(:organization) { create(:organization) } - - before do - switch_to_host(organization.host) - visit decidim.root_path - end + include_context "when visiting organization homepage" it "renders the home page" do expect(page).to have_content("Home") diff --git a/spec/system/platoniq_footer_spec.rb b/spec/system/platoniq_footer_spec.rb new file mode 100644 index 0000000..3ec4c1b --- /dev/null +++ b/spec/system/platoniq_footer_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe "Visit the home page", perform_enqueued: true do + include_context "when visiting organization homepage" + + it "renders the home page" do + expect(page).to have_content("Home") + end +end