From a85e500bb1f694f1a6a2f424e2f72cf431dfdc59 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 29 Sep 2020 22:36:13 +0100 Subject: [PATCH] moves content_spec.rb into /configuration and adds an href string, incresing Redcarpet test coverage --- .../admin/configuration/content_spec.rb | 54 +++++++++++++++++++ spec/features/admin/content_spec.rb | 51 ------------------ 2 files changed, 54 insertions(+), 51 deletions(-) create mode 100644 spec/features/admin/configuration/content_spec.rb delete mode 100644 spec/features/admin/content_spec.rb diff --git a/spec/features/admin/configuration/content_spec.rb b/spec/features/admin/configuration/content_spec.rb new file mode 100644 index 0000000000..8ef12213ad --- /dev/null +++ b/spec/features/admin/configuration/content_spec.rb @@ -0,0 +1,54 @@ +require "spec_helper" + +describe " + As a site administrator + I want to configure the site content +" do + include AuthenticationHelper + include WebHelper + + before do + login_as_admin_and_visit spree.edit_admin_general_settings_path + click_link "Content" + end + + it "fills in a setting shows the result on the home page" do + fill_in "footer_facebook_url", with: "" + fill_in "footer_twitter_url", with: "http://twitter.com/me" + fill_in "footer_links_md", with: \ + "[markdown link](/:/?#@!$&'()*+,;=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ)" + click_button "Update" + expect(page).to have_content "Your content has been successfully updated!" + + visit root_path + + # Then social media icons are only shown if they have a value + expect(page).not_to have_selector "i.ofn-i_044-facebook" + expect(page).to have_selector "i.ofn-i_041-twitter" + + # And markdown is rendered + # expect(page).to have_link "markdown link" and the correct href + expect(page).to have_selector :link, "markdown link", href: \ + "/:/?#@!$&'()*+,;=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + end + + it "uploads logos" do + attach_file "logo", Rails.root.join('app/assets/images/logo-white.png') + click_button "Update" + expect(page).to have_content "Your content has been successfully updated!" + + expect(ContentConfig.logo.to_s).to include "logo-white" + end + + it "sets the user guide link" do + fill_in "user_guide_link", with: "http://www.openfoodnetwork.org/platform/user-guide/" + click_button "Update" + + expect(page).to have_content "Your content has been successfully updated!" + + visit spree.admin_dashboard_path + + expect(page).to have_link("User Guide", href: "http://www.openfoodnetwork.org/platform/user-guide/") + expect(find_link("User Guide")[:target]).to eq("_blank") + end +end diff --git a/spec/features/admin/content_spec.rb b/spec/features/admin/content_spec.rb deleted file mode 100644 index cdc4971839..0000000000 --- a/spec/features/admin/content_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'spec_helper' - -feature ' - As a site administrator - I want to configure the site content -' do - include AuthenticationHelper - include WebHelper - - before do - login_as_admin_and_visit spree.edit_admin_general_settings_path - click_link 'Content' - end - - scenario "filling in a setting shows the result on the home page" do - fill_in 'footer_facebook_url', with: '' - fill_in 'footer_twitter_url', with: 'http://twitter.com/me' - fill_in 'footer_links_md', with: '[markdown link](/)' - click_button 'Update' - expect(page).to have_content 'Your content has been successfully updated!' - - visit root_path - - # Then social media icons are only shown if they have a value - expect(page).not_to have_selector 'i.ofn-i_044-facebook' - expect(page).to have_selector 'i.ofn-i_041-twitter' - - # And markdown is rendered - expect(page).to have_link 'markdown link' - end - - scenario "uploading logos" do - attach_file 'logo', "#{Rails.root}/app/assets/images/logo-white.png" - click_button 'Update' - expect(page).to have_content 'Your content has been successfully updated!' - - expect(ContentConfig.logo.to_s).to include "logo-white" - end - - scenario "setting user guide link" do - fill_in 'user_guide_link', with: 'http://www.openfoodnetwork.org/platform/user-guide/' - click_button 'Update' - - expect(page).to have_content 'Your content has been successfully updated!' - - visit spree.admin_dashboard_path - - expect(page).to have_link('User Guide', href: 'http://www.openfoodnetwork.org/platform/user-guide/') - expect(find_link('User Guide')[:target]).to eq('_blank') - end -end