From 5df77b23d9c8a40bc2903a8059f0f24933c837a9 Mon Sep 17 00:00:00 2001 From: Martha Thompson <437455+MothOnMars@users.noreply.github.com> Date: Tue, 18 May 2021 11:02:00 -0400 Subject: [PATCH] SRCH-2150 remove legacy "advanced" header/footer (#726) - remove admin center controls for the advanced header/footer - bump simplecov - remove unused gems - bundle updated gems --- .simplecov | 2 +- Gemfile | 13 +- Gemfile.lock | 120 +++-- .../sites/validate_display_html.js.coffee | 18 - app/controllers/application_controller.rb | 16 +- app/controllers/image_searches_controller.rb | 1 - app/controllers/searches_controller.rb | 3 +- .../sites/header_and_footers_controller.rb | 65 +-- app/controllers/sites/sites_controller.rb | 1 - app/helpers/affiliate_helper.rb | 68 +-- app/helpers/header_and_footer_helper.rb | 27 +- app/mailers/emailer.rb | 7 - app/models/affiliate.rb | 183 +------- app/models/email_template.rb | 2 - app/views/layouts/searches.html.haml | 4 +- .../_advanced_mode_action_bar_items.html.haml | 13 - .../_advanced_mode_form.html.haml | 12 - ...le_mode_form.html.haml => _form.html.haml} | 0 .../_simple_mode_action_bar_items.html.haml | 3 - .../_validate_html_form.html.haml | 5 - .../sites/header_and_footers/edit.html.haml | 8 +- .../affiliate_header_footer_change.html.erb | 31 -- features/admin_center_manage_display.feature | 86 +--- features/legacy_search.feature | 9 - features/searches.feature | 9 - features/step_definitions/within_steps.rb | 2 - features/support/paths.rb | 2 - ...r_Footer.yml => Editing_Header_Footer.yml} | 181 ++++---- lib/renderers/css_to_nested_css.rb | 24 - lib/xml_processor.rb | 15 - spec/controllers/searches_controller_spec.rb | 10 +- .../sites/sites_controller_spec.rb | 1 - spec/helpers/affiliate_helper_spec.rb | 42 -- spec/models/affiliate_spec.rb | 425 +----------------- 34 files changed, 193 insertions(+), 1215 deletions(-) delete mode 100644 app/assets/javascripts/sites/validate_display_html.js.coffee delete mode 100644 app/views/sites/header_and_footers/_advanced_mode_action_bar_items.html.haml delete mode 100644 app/views/sites/header_and_footers/_advanced_mode_form.html.haml rename app/views/sites/header_and_footers/{_simple_mode_form.html.haml => _form.html.haml} (100%) delete mode 100644 app/views/sites/header_and_footers/_simple_mode_action_bar_items.html.haml delete mode 100644 app/views/sites/header_and_footers/_validate_html_form.html.haml delete mode 100644 db/email_templates/affiliate_header_footer_change.html.erb rename features/vcr_cassettes/Manage_Display/{Editing_Managed_Header_Footer.yml => Editing_Header_Footer.yml} (51%) delete mode 100644 lib/renderers/css_to_nested_css.rb delete mode 100644 lib/xml_processor.rb diff --git a/.simplecov b/.simplecov index 1b10520ba7..e25b9581d0 100644 --- a/.simplecov +++ b/.simplecov @@ -18,7 +18,7 @@ SimpleCov.start 'rails' do add_filter '/.bundler/' add_filter '/app/helpers/admin/' add_filter '/lib/i14y_collections.rb' - add_filter '/app/.*/.*azure.*.rb' + add_filter 'azure' add_filter '/lib/setup_resque.rb' add_group 'Engines', 'app/engines' diff --git a/Gemfile b/Gemfile index e0da1bfe56..95901a3079 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,6 @@ gem 'omniauth_login_dot_gov', git: 'https://github.com/18f/omniauth_login_dot_go ref: '08ce9b5322efb2d82b2df3f6d774308c4028ee6c' gem 'omniauth-rails_csrf_protection', '~> 0.1.2' gem 'airbrake', '~> 7.1.1' -gem 'yajl-ruby', '~> 1.3.1', :require => 'yajl' gem 'redis', '~> 4.0.1' gem 'redis-namespace', '~> 1.6.0' gem 'redis-rails', '~> 5.0.2' @@ -27,7 +26,6 @@ gem 'resque-priority', :git => 'https://github.com/GSA/resque-priority.git' gem 'resque-timeout', '~> 1.0.0' gem 'resque-lock-timeout', '~> 0.4.5' gem 'resque-scheduler', '~> 4.3.1' -gem 'cocaine', '~> 0.5.8' gem 'paperclip', '~> 5.2.0' gem 'googlecharts', '~> 1.6.12' gem 'tweetstream', '~> 2.6.1' # no longer maintained? @@ -35,8 +33,7 @@ gem 'twitter', git: 'https://github.com/GSA/twitter.git', branch: '5-stable' gem 'flickraw', '~> 0.9.9' gem 'active_scaffold', '~> 3.5.0' gem 'active_scaffold_export', git: 'https://github.com/naaano/active_scaffold_export' -gem 'us_states_select', '~> 1.2.0', :git => 'https://github.com/jeremydurham/us-state-select-plugin.git', :require => 'us_states_select' -gem 'mobile-fu', '~> 1.4.0' +gem 'mobile-fu', '~> 1.4.0' # deprecated - legacy SERP gem "recaptcha", '~> 4.6.3', :require => "recaptcha/rails" gem 'newrelic_rpm', '~> 5.0.0' gem 'american_date', '~> 1.1.1' @@ -46,13 +43,11 @@ gem 'sass-rails', '~> 5.0.7' gem 'google_visualr', git: 'https://github.com/winston/google_visualr', ref: '17b97114a345baadd011e7b442b9a6c91a2b7ab5' -gem 'oj', '~> 3.3.10' gem 'faraday_middleware', '~> 0.12.2' gem 'net-http-persistent', '~> 2.9.3' gem 'rash_alt', git: 'https://github.com/MothOnMars/rash_alt', ref: 'bbd107061fbb066709523c68de4a217a76a8a945', require: 'rash' gem 'geoip', '~> 1.6.3' -gem 'us_states', '~> 0.1.1' -gem 'htmlentities', '~> 4.3.4' +gem 'htmlentities', '~> 4.3.4' # deprecated - only used in Google web search gem 'html_truncator', '~> 0.4.2' gem 'addressable', '~> 2.5.2' gem 'select2-rails', '~> 4.0.3' @@ -73,6 +68,7 @@ gem 'sitelink_generator', git: 'https://github.com/GSA/sitelink_generator', ref: gem 'typhoeus', '~> 1.3.0' gem 'activerecord-validate_unique_child_attribute', require: 'active_record/validate_unique_child_attribute' +# deprecated - jwt, grape, and grape-entity are only used by Search Consumer gem 'jwt', '~> 1.5.6' gem 'grape', '~> 1.1' gem 'grape-entity', '~> 0.6.0' @@ -82,7 +78,6 @@ gem 'retry_block', '~> 1.2.0' gem 'aws-sdk', '< 3.0' gem 'colorize', '~> 0.8.1' gem 'dogstatsd-ruby', '~> 3.2.0' -gem 'test-unit', '~> 3.2.7' gem 'http', '~> 1.0' gem 'robots_tag_parser', '~> 0.1.0', git: 'https://github.com/GSA/robots_tag_parser' gem 'loofah', '~> 2.9.0' @@ -159,7 +154,7 @@ end group :test do gem 'capybara-screenshot' - gem 'simplecov', '~> 0.15.1', require: false + gem 'simplecov', '~> 0.17.0', require: false # Limiting the cucumber version until v4 is compatible with VCR # https://github.com/vcr/vcr/issues/825 gem 'cucumber', '~> 3.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 9ad9ff44d6..1915dce295 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,13 +88,6 @@ GIT font-awesome-grunticon-rails (0.2.0) railties (>= 3.2) -GIT - remote: https://github.com/jeremydurham/us-state-select-plugin.git - revision: aa69cc1f23eea7cadd5acdcda74a0333d41852c1 - specs: - us_states_select (1.2.0) - rails (>= 1.2) - GIT remote: https://github.com/naaano/active_scaffold_export revision: 879ceb549b871ebb597ae5339a2e67498beb70d1 @@ -114,25 +107,25 @@ GEM specs: aasm (4.12.3) concurrent-ruby (~> 1.0) - actioncable (5.2.5) - actionpack (= 5.2.5) + actioncable (5.2.6) + actionpack (= 5.2.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.5) - actionpack (= 5.2.5) - actionview (= 5.2.5) - activejob (= 5.2.5) + actionmailer (5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.5) - actionview (= 5.2.5) - activesupport (= 5.2.5) + actionpack (5.2.6) + actionview (= 5.2.6) + activesupport (= 5.2.6) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.5) - activesupport (= 5.2.5) + actionview (5.2.6) + activesupport (= 5.2.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -143,24 +136,24 @@ GEM active_scheduler (0.5.0) activejob (>= 4.2.0) rake - activejob (5.2.5) - activesupport (= 5.2.5) + activejob (5.2.6) + activesupport (= 5.2.6) globalid (>= 0.3.6) - activemodel (5.2.5) - activesupport (= 5.2.5) - activerecord (5.2.5) - activemodel (= 5.2.5) - activesupport (= 5.2.5) + activemodel (5.2.6) + activesupport (= 5.2.6) + activerecord (5.2.6) + activemodel (= 5.2.6) + activesupport (= 5.2.6) arel (>= 9.0) activerecord-validate_unique_child_attribute (0.0.1) activemodel (>= 3.2.0) activerecord (>= 3.2.0) activesupport (>= 3.2.0) - activestorage (5.2.5) - actionpack (= 5.2.5) - activerecord (= 5.2.5) + activestorage (5.2.6) + actionpack (= 5.2.6) + activerecord (= 5.2.6) marcel (~> 1.0.0) - activesupport (5.2.5) + activesupport (5.2.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -285,13 +278,13 @@ GEM cucumber-tag_expressions (1.1.1) cucumber-wire (0.0.1) curb (0.9.11) - daemons (1.3.1) + daemons (1.4.0) database_cleaner (1.7.0) declarative (0.0.20) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) diff-lcs (1.4.4) - docile (1.1.5) + docile (1.4.0) dogstatsd-ruby (3.2.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) @@ -488,7 +481,7 @@ GEM mobile-fu (1.4.0) rack-mobile-detect rails - moneta (1.4.1) + moneta (1.4.2) mono_logger (1.1.1) multi_json (1.15.0) multi_test (0.1.2) @@ -506,7 +499,6 @@ GEM nokogiri (1.11.3) mini_portile2 (~> 2.5.0) racc (~> 1.4) - oj (3.3.10) omniauth (1.4.3) hashie (>= 1.2, < 4) rack (>= 1.6.2, < 3) @@ -522,13 +514,12 @@ GEM mime-types mimemagic (~> 0.3.0) parallel (1.20.1) - parser (3.0.1.0) + parser (3.0.1.1) ast (~> 2.4.1) poltergeist (1.18.1) capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - power_assert (2.0.0) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -554,18 +545,18 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.5) - actioncable (= 5.2.5) - actionmailer (= 5.2.5) - actionpack (= 5.2.5) - actionview (= 5.2.5) - activejob (= 5.2.5) - activemodel (= 5.2.5) - activerecord (= 5.2.5) - activestorage (= 5.2.5) - activesupport (= 5.2.5) + rails (5.2.6) + actioncable (= 5.2.6) + actionmailer (= 5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) + activemodel (= 5.2.6) + activerecord (= 5.2.6) + activestorage (= 5.2.6) + activesupport (= 5.2.6) bundler (>= 1.3.0) - railties (= 5.2.5) + railties (= 5.2.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -581,15 +572,15 @@ GEM railties (>= 5.0, < 6) rails-observers (0.1.5) activemodel (>= 4.0) - railties (5.2.5) - actionpack (= 5.2.5) - activesupport (= 5.2.5) + railties (5.2.6) + actionpack (= 5.2.6) + activesupport (= 5.2.6) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) rake (12.3.3) - rb-fsevent (0.10.4) + rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) recaptcha (4.6.6) @@ -683,15 +674,15 @@ GEM rubocop-ast (>= 1.2.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) - rubocop-performance (1.11.0) + rubocop-ast (1.5.0) + parser (>= 3.0.1.1) + rubocop-performance (1.11.3) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.9.1) + rubocop-rails (2.10.1) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.90.0, < 2.0) + rubocop (>= 1.7.0, < 2.0) rubocop-rake (0.5.1) rubocop rubocop-rspec (2.3.0) @@ -733,8 +724,8 @@ GEM jwt (>= 1.5, < 3.0) multi_json (~> 1.10) simple_oauth (0.3.1) - simplecov (0.15.1) - docile (~> 1.1.0) + simplecov (0.17.1) + docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) @@ -752,9 +743,8 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) temple (0.8.2) - terminal-table (1.6.0) - test-unit (3.2.9) - power_assert + terminal-table (3.0.1) + unicode-display_width (>= 1.1.1, < 3) therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref @@ -788,7 +778,6 @@ GEM unf_ext unf_ext (0.0.7.7) unicode-display_width (2.0.0) - us_states (0.1.1) validate_url (0.2.0) activemodel (>= 3.0.0) vcr (4.0.0) @@ -815,7 +804,6 @@ GEM will_paginate (>= 3.0.3) xpath (3.2.0) nokogiri (~> 1.8) - yajl-ruby (1.3.1) yui-compressor (0.12.0) PLATFORMS @@ -837,7 +825,6 @@ DEPENDENCIES capybara (~> 2.18.0) capybara-screenshot cld3 (~> 3.2.3) - cocaine (~> 0.5.8) coffee-rails (~> 4.2.2) colorize (~> 0.8.1) compass-blueprint (~> 1.0.0) @@ -887,7 +874,6 @@ DEPENDENCIES net-http-persistent (~> 2.9.3) newrelic_rpm (~> 5.0.0) nokogiri (~> 1.11.1) - oj (~> 3.3.10) omniauth-rails_csrf_protection (~> 0.1.2) omniauth_login_dot_gov! paperclip (~> 5.2.0) @@ -929,10 +915,9 @@ DEPENDENCIES select2-rails (~> 4.0.3) shoulda-kept-assign-to (~> 1.1.0) shoulda-matchers (~> 4.1.1) - simplecov (~> 0.15.1) + simplecov (~> 0.17.0) sitelink_generator! spring (~> 2.0) - test-unit (~> 3.2.7) therubyracer (~> 0.12.3) truncator (~> 0.1.7) turbolinks (~> 5.0.1) @@ -941,8 +926,6 @@ DEPENDENCIES twitter-typeahead-rails (~> 0.11.1) typhoeus (~> 1.3.0) uglifier (~> 4.1.2) - us_states (~> 0.1.1) - us_states_select (~> 1.2.0)! validate_url (= 0.2.0) vcr (~> 4.0) virtus (~> 1.0.5) @@ -950,7 +933,6 @@ DEPENDENCIES webmock (~> 3.8.3) will_paginate (~> 3.1.6) will_paginate-bootstrap (~> 1.0.1) - yajl-ruby (~> 1.3.1) yui-compressor (~> 0.12.0) BUNDLED WITH diff --git a/app/assets/javascripts/sites/validate_display_html.js.coffee b/app/assets/javascripts/sites/validate_display_html.js.coffee deleted file mode 100644 index 22110061cb..0000000000 --- a/app/assets/javascripts/sites/validate_display_html.js.coffee +++ /dev/null @@ -1,18 +0,0 @@ -generateFullHtmlDocument = (targetId, content) -> - docType = '' - docPrefix = "#{targetId}\n\n
\n"; - docSuffix = "
\n\n"; - "#{docType}\n#{docPrefix}
\n#{content}\n
\n#{docSuffix}" - - -validateDisplayHtml = (sourceSelector, targetId) -> - val = $(sourceSelector).val(); - htmlDoc = generateFullHtmlDocument targetId, val - $('#content').val htmlDoc - $('#validator-form').submit(); - -$(document).on 'click', '#validate-header, #validate-footer', (e) -> - e.preventDefault(); - sourceSelector = $(this).data('sourceSelector') - targetId = sourceSelector.split('_').pop() - validateDisplayHtml sourceSelector, targetId diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6f1ec173cb..f6f0b2bfbb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base DUBLIN_CORE_PARAM_KEYS = %i(contributor publisher subject).freeze FILTER_PARAM_KEYS = %i(since_date sort_by tbs until_date).freeze - PERMITTED_PARAM_KEYS = %i( + PERMITTED_PARAM_KEYS = %i[ affiliate autodiscovery_url channel @@ -27,11 +27,10 @@ class ApplicationController < ActionController::Base page query staged - strictui siteexclude sitelimit utf8 - ).concat(ADVANCED_PARAM_KEYS). + ].concat(ADVANCED_PARAM_KEYS). concat(DUBLIN_CORE_PARAM_KEYS). concat(FILTER_PARAM_KEYS).freeze @@ -52,17 +51,6 @@ def redirect_unless_affiliate end end - def set_header_footer_fields - if @affiliate && permitted_params['staged'] - @affiliate.nested_header_footer_css = @affiliate.staged_nested_header_footer_css - @affiliate.header = @affiliate.staged_header - @affiliate.footer = @affiliate.staged_footer - @affiliate.uses_managed_header_footer = @affiliate.staged_uses_managed_header_footer - end - - @affiliate.use_strictui if permitted_params[:strictui] - end - def set_locale_based_on_affiliate_locale I18n.locale = @affiliate.locale.to_sym end diff --git a/app/controllers/image_searches_controller.rb b/app/controllers/image_searches_controller.rb index 5464bf5be9..b93cc1f160 100644 --- a/app/controllers/image_searches_controller.rb +++ b/app/controllers/image_searches_controller.rb @@ -6,7 +6,6 @@ class ImageSearchesController < ApplicationController layout 'searches' before_action :set_affiliate, :set_locale_based_on_affiliate_locale - before_action :set_header_footer_fields before_action :set_search_options before_action :force_request_format diff --git a/app/controllers/searches_controller.rb b/app/controllers/searches_controller.rb index f282c07bfb..bf896c0de5 100644 --- a/app/controllers/searches_controller.rb +++ b/app/controllers/searches_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SearchesController < ApplicationController include MobileFriendlyController has_no_mobile_fu_for :advanced @@ -9,7 +11,6 @@ class SearchesController < ApplicationController #eventually all the searches should be redirected, but currently we're doing it as-needed #to ensure that the correct params are being passed, etc. before_action :redirect_to_search_consumer, only: [:index, :news, :docs] - before_action :set_header_footer_fields before_action :set_web_search_options, :only => [:advanced, :index] before_action :set_docs_search_options, :only => :docs before_action :set_news_search_options, :only => [:news, :video_news] diff --git a/app/controllers/sites/header_and_footers_controller.rb b/app/controllers/sites/header_and_footers_controller.rb index 6104ec49fc..35f70c2da9 100644 --- a/app/controllers/sites/header_and_footers_controller.rb +++ b/app/controllers/sites/header_and_footers_controller.rb @@ -1,9 +1,6 @@ -class Sites::HeaderAndFootersController < Sites::SetupSiteController - SIMPLE_MODE = 'simple'.freeze - ADVANCED_MODE = 'advanced'.freeze - MODES = [SIMPLE_MODE, ADVANCED_MODE].freeze +# frozen_string_literal: true - before_action :assign_mode +class Sites::HeaderAndFootersController < Sites::SetupSiteController before_action :build_header_links, only: [:edit, :new_header_link] before_action :build_footer_links, only: [:edit, :new_footer_link] @@ -21,15 +18,7 @@ def new_footer_link end def update - simple_mode? ? update_header_footer_links : update_custom_header_footer - end - - def update_header_footer_links - @site.staged_uses_managed_header_footer = true - @site.uses_managed_header_footer = true - @site.has_staged_content = false - - if @site.update_attributes(simple_mode_site_params) + if @site.update_attributes(site_params) redirect_to edit_site_header_and_footer_path(@site), flash: { success: 'You have updated your header and footer information.' } else @@ -39,41 +28,8 @@ def update_header_footer_links end end - def update_custom_header_footer - if params[:commit] == 'Make Live' - if @site.update_attributes_for_live(advanced_mode_site_params) - Emailer.affiliate_header_footer_change(@site).deliver_now if @site.has_changed_header_or_footer - redirect_to edit_site_header_and_footer_path(@site), - flash: { success: 'You have saved header and footer changes to your live site.' } - else - render :edit - end - elsif params[:commit] == 'Save for Preview' - if @site.update_attributes_for_staging(advanced_mode_site_params) - redirect_to edit_site_header_and_footer_path(@site), - flash: { success: 'You have saved header and footer changes for preview.' } - else - render :edit - end - elsif params[:commit] == 'Cancel Changes' - @site.cancel_staged_changes - redirect_to edit_site_header_and_footer_path(@site), - flash: { success: 'You have cancelled header and footer changes.' } - end - end - private - def assign_mode - @mode = params[:mode] if MODES.include? params[:mode] - @mode = SIMPLE_MODE if @site.force_mobile_format? - @mode ||= @site.staged_uses_managed_header_footer? ? SIMPLE_MODE : ADVANCED_MODE - end - - def simple_mode? - SIMPLE_MODE == @mode - end - def build_header_links @site.managed_header_links = [{}] if @site.managed_header_links.blank? end @@ -82,8 +38,8 @@ def build_footer_links @site.managed_footer_links = [{}] if @site.managed_footer_links.blank? end - def simple_mode_site_params - simple_mode_params = params.require(:site). + def site_params + site_params = params.require(:site). permit({ css_property_hash: %i(menu_button_alignment) }, :header_tagline, :header_tagline_url, @@ -91,14 +47,7 @@ def simple_mode_site_params :header_tagline_logo, { managed_footer_links_attributes: %i(position title url) }, { managed_header_links_attributes: %i(position title url) }) - simple_mode_params[:css_property_hash] &&= @site.css_property_hash.merge(simple_mode_params[:css_property_hash]) - simple_mode_params - end - - def advanced_mode_site_params - params.require(:site).permit(:staged_footer, - :staged_header, - :staged_header_footer_css). - merge(staged_uses_managed_header_footer: '0') + site_params[:css_property_hash] &&= @site.css_property_hash.merge(site_params[:css_property_hash]) + site_params end end diff --git a/app/controllers/sites/sites_controller.rb b/app/controllers/sites/sites_controller.rb index e59b7bd8f8..1bf13bef79 100644 --- a/app/controllers/sites/sites_controller.rb +++ b/app/controllers/sites/sites_controller.rb @@ -26,7 +26,6 @@ def create @site = Affiliate.new(site_params) @site.users << current_user if @site.save - @site.push_staged_changes @site.assign_sitelink_generator_names! Emailer.new_affiliate_site(@site, current_user).deliver_now SiteAutodiscoverer.new(@site).run diff --git a/app/helpers/affiliate_helper.rb b/app/helpers/affiliate_helper.rb index 1e90bbfcb9..8183657743 100644 --- a/app/helpers/affiliate_helper.rb +++ b/app/helpers/affiliate_helper.rb @@ -1,70 +1,4 @@ module AffiliateHelper - def render_affiliate_header(affiliate) - if affiliate.uses_managed_header_footer? - html = render_managed_header(affiliate) - if affiliate.managed_header_links.present? - html << content_tag(:div, render_managed_links(affiliate.managed_header_links).html_safe, :class => 'managed-header-footer-links-wrapper') - end - content_tag(:div, html.html_safe, :id => 'header', :class => 'managed') unless html.blank? - elsif !affiliate.uses_managed_header_footer? and affiliate.header.present? - content_tag(:div, affiliate.header.html_safe, :id => 'header', :class => 'header-footer') - end - end - - def render_managed_header(affiliate) - content = '' - if affiliate.header_image_file_name.present? - begin - image_style = 'display: inline-block;' - content << link_to_unless(affiliate.website.blank?, image_tag(affiliate.header_image.url, :alt => 'logo', :style => "#{image_style}"), affiliate.website) - rescue Exception - nil - end - else - style = 'font-family: Georgia, serif; font-size: 50px; display: inline-block; margin: 0;' - content << link_to_unless(affiliate.website.blank?, content_tag(:div, affiliate.display_name, style: style), affiliate.website) - end - content.blank? ? content : content_tag(:div, content.html_safe, id: 'managed_header').html_safe - end - - def render_managed_links(links) - content = '' - links.each_with_index do |link, index| - options = {:class => 'first'} if index == 0 - content << content_tag(:li, link_to(link[:title], link[:url], options).html_safe) << "\n" - end - content_tag(:ul, content.html_safe, :class => 'managed-header-footer-links') - end - - def render_affiliate_footer(affiliate) - if affiliate.uses_managed_header_footer? and affiliate.managed_footer_links.present? - html = content_tag(:div, render_managed_links(affiliate.managed_footer_links).html_safe, :class => 'managed-header-footer-links-wrapper') - content_tag(:div, html.html_safe, id: 'usasearch_footer', class: 'managed') - elsif !affiliate.uses_managed_header_footer? and affiliate.footer.present? - content_tag(:div, affiliate.footer.html_safe, id: 'usasearch_footer', class: 'header-footer') - end - end - - def render_affiliate_body_class(affiliate) - classes = "one-serp default #{I18n.locale}" - classes << ' with-content-border' if affiliate.show_content_border? - classes << ' with-content-box-shadow' if affiliate.show_content_box_shadow? - classes - end - - def render_affiliate_body_style(affiliate) - style = '' - background_color = render_affiliate_css_property_value(affiliate.css_property_hash, :page_background_color) - background_image_url = affiliate.page_background_image.url rescue nil if affiliate.page_background_image_file_name.present? - if background_image_url.present? - background_repeat = render_affiliate_css_property_value(affiliate.css_property_hash, :page_background_image_repeat) - style << "background: #{background_color} url(#{background_image_url}) #{background_repeat} center top" - else - style << "background-color: #{background_color}" - end - style - end - def render_embed_code_javascript(affiliate) embed_code = <<-JS var usasearch_config = { siteHandle:"#{affiliate.name}" }; @@ -77,11 +11,13 @@ def render_embed_code_javascript(affiliate) javascript_tag embed_code end + # deprecated - Search Consumer def available_templates(affiliate) templates = affiliate.available_templates templates.blank? ? [Template.default] : templates end + # deprecated - Search Consumer def unavailable_templates(affiliate) Template.all - available_templates(affiliate) end diff --git a/app/helpers/header_and_footer_helper.rb b/app/helpers/header_and_footer_helper.rb index e2827eb9c6..c402eda8bf 100644 --- a/app/helpers/header_and_footer_helper.rb +++ b/app/helpers/header_and_footer_helper.rb @@ -1,12 +1,6 @@ -module HeaderAndFooterHelper - def save_header_footer_button(form, site) - if site.staged_uses_managed_header_footer? && site.uses_managed_header_footer? - form.submit 'Save', class: 'btn disabled submit disabled', disabled: true - else - form.submit 'Save', class: 'btn btn-primary submit' - end - end +# frozen_string_literal: true +module HeaderAndFooterHelper def link_to_add_new_site_header_link(title, site) instrumented_link_to title, new_header_link_site_header_and_footer_path(site), site.managed_header_links.length, 'site-header-link' end @@ -14,21 +8,4 @@ def link_to_add_new_site_header_link(title, site) def link_to_add_new_site_footer_link(title, site) instrumented_link_to title, new_footer_link_site_header_and_footer_path(site), site.managed_footer_links.length, 'site-footer-link' end - - def save_for_preview_button(form, site) - if site.staged_uses_managed_header_footer? && - (site.staged_header.present? || site.staged_footer.present?) - form.submit 'Save for Preview', class: 'btn btn-primary submit' - else - form.submit 'Save for Preview', class: 'btn submit disabled', disabled: true - end - end - - def make_live_button(form, site) - if site.has_staged_content? || site.uses_managed_header_footer? - form.submit 'Make Live', class: 'submit btn-flat', id: 'make-live' - else - form.submit 'Make Live', class: 'submit btn-flat disabled', disabled: true, id: 'make-live' - end - end end diff --git a/app/mailers/emailer.rb b/app/mailers/emailer.rb index 224f345c38..f418e64fbd 100644 --- a/app/mailers/emailer.rb +++ b/app/mailers/emailer.rb @@ -81,13 +81,6 @@ def welcome_to_new_user_added_by_affiliate(affiliate, user, current_user) generic_user_html_email(user, __method__) end - def affiliate_header_footer_change(affiliate) - recipients = affiliate.users.collect(&:email).join(', ') - @affiliate = affiliate - setup_email(recipients, __method__) - send_mail(:text) - end - def affiliate_yearly_report(user, year) headers['Content-Type'] = 'text/html' jan1 = Date.civil(year, 1, 1) diff --git a/app/models/affiliate.rb b/app/models/affiliate.rb index f8d1b912a0..ffb3a7126b 100644 --- a/app/models/affiliate.rb +++ b/app/models/affiliate.rb @@ -7,7 +7,6 @@ class Affiliate < ApplicationRecord extend HumanAttributeName extend HashColumnsAccessible include Dupable - include XmlProcessor include LogstashPrefix MAXIMUM_IMAGE_SIZE_IN_KB = 512 @@ -177,13 +176,11 @@ def make_unavailable(template_ids) :validate_managed_footer_links, :validate_managed_header_links, :validate_managed_no_results_pages_alt_links, - :validate_staged_header_footer, - :validate_staged_header_footer_css, :language_valid, :validate_managed_no_results_pages_guidance_text after_validation :update_error_keys - before_save :set_css_properties, :generate_look_and_feel_css, :sanitize_staged_header_footer, :set_json_fields, :set_search_labels + before_save :set_css_properties, :generate_look_and_feel_css, :set_json_fields, :set_search_labels before_update :clear_existing_attachments after_commit :normalize_site_domains, on: :create after_commit :remove_boosted_contents_from_index, on: :destroy @@ -194,7 +191,6 @@ def make_unavailable(template_ids) attr_writer :css_property_hash attr_accessor :mark_mobile_logo_for_deletion, :mark_header_tagline_logo_for_deletion, - :is_validate_staged_header_footer, :managed_header_links_attributes, :managed_footer_links_attributes, :managed_no_results_pages_alt_links_attributes @@ -249,8 +245,6 @@ def make_unavailable(template_ids) show_content_box_shadow: '0' }.merge(THEMES[:default]) - ATTRIBUTES_WITH_STAGED_AND_LIVE = %w(header footer header_footer_css nested_header_footer_css uses_managed_header_footer) - CUSTOM_INDEXING_LANGUAGES = %w(en es) COMMON_INDEXING_LANGUAGE = 'babel' @@ -259,21 +253,30 @@ def indexing_locale CUSTOM_INDEXING_LANGUAGES.include?(self.locale) ? self.locale : COMMON_INDEXING_LANGUAGE end - define_hash_columns_accessors column_name_method: :previous_fields, fields: [:previous_header, :previous_footer] define_hash_columns_accessors column_name_method: :live_fields, - fields: [:header, :footer, - :header_footer_css, :nested_header_footer_css, - :managed_header_links, :managed_footer_links, - :external_tracking_code, :submitted_external_tracking_code, - :look_and_feel_css, :mobile_look_and_feel_css, - :logo_alt_text, :sitelink_generator_names, + fields: [:header, # legacy SERP + :footer, # legacy SERP + :header_footer_css, # legacy SERP + :nested_header_footer_css, # legacy SERP + :managed_header_links, + :managed_footer_links, + :external_tracking_code, + :submitted_external_tracking_code, + :look_and_feel_css, # legacy SERP + :mobile_look_and_feel_css, + :logo_alt_text, + :sitelink_generator_names, :header_tagline, :header_tagline_url, - :page_one_more_results_pointer, :no_results_pointer, + :page_one_more_results_pointer, + :no_results_pointer, :footer_fragment, - :navigation_dropdown_label, :related_sites_dropdown_label, + :navigation_dropdown_label, + :related_sites_dropdown_label, :additional_guidance_text, :managed_no_results_pages_alt_links] + + # deprecated - legacy SERP define_hash_columns_accessors column_name_method: :staged_fields, fields: [:staged_header, :staged_footer, :staged_header_footer_css, :staged_nested_header_footer_css] @@ -320,54 +323,10 @@ def has_multiple_domains? site_domains.count > 1 end - def update_attributes_for_staging(attributes) - set_is_validate_staged_header_footer attributes - attributes[:has_staged_content] = true - self.update_attributes(attributes) - end - def recent_user_activity users.collect(&:last_request_at).compact.max end - def update_attributes_for_live(attributes) - set_is_validate_staged_header_footer attributes - transaction do - if self.update_attributes(attributes) - self.previous_header = header - self.previous_footer = footer - set_attributes_from_staged_to_live - self.has_staged_content = false - self.save! - true - else - false - end - end - end - - def push_staged_changes - self.previous_header = header - self.previous_footer = footer - set_attributes_from_staged_to_live - self.has_staged_content = false - save! - end - - def cancel_staged_changes - set_attributes_from_live_to_staged - self.has_staged_content = false - save! - end - - def sync_staged_attributes - self.cancel_staged_changes unless self.has_staged_content? - end - - def has_changed_header_or_footer - self.header != self.previous_header or self.footer != self.previous_footer - end - def css_property_hash(reload = false) @css_property_hash = nil if reload if theme.to_sym == :default @@ -409,38 +368,12 @@ def show_content_box_shadow? css_property_hash[:show_content_box_shadow] == '1' end - def set_attributes_from_live_to_staged - ATTRIBUTES_WITH_STAGED_AND_LIVE.each do |field| - self.send("staged_#{field}=", self.send("#{field}")) - end - end - - def set_attributes_from_staged_to_live - ATTRIBUTES_WITH_STAGED_AND_LIVE.each do |field| - self.send("#{field}=", self.send("staged_#{field}")) - end - end - def refresh_indexed_documents(scope) indexed_documents.select(:id).send(scope.to_sym).find_in_batches(:batch_size => batch_size(scope)) do |batch| Resque.enqueue_with_priority(:low, AffiliateIndexedDocumentFetcher, id, batch.first.id, batch.last.id, scope) end end - def sanitized_header - sanitize_html header - end - - def sanitized_footer - sanitize_html footer - end - - def use_strictui - self.header = sanitized_header - self.footer = sanitized_footer - self.external_css_url = nil - end - def unused_features features.any? ? Feature.where('id not in (?)', features.collect(&:id)) : Feature.all end @@ -741,8 +674,6 @@ def validate_managed_links(links, link_type) def set_default_fields self.theme = THEMES.keys.first.to_s if theme.blank? - self.uses_managed_header_footer = true if uses_managed_header_footer.nil? - self.staged_uses_managed_header_footer = true if staged_uses_managed_header_footer.nil? @css_property_hash = ActiveSupport::OrderedHash.new if @css_property_hash.nil? true end @@ -751,52 +682,10 @@ def set_css_properties self.css_properties = @css_property_hash.to_json unless @css_property_hash.blank? end - def validate_staged_header_footer_css - return unless is_validate_staged_header_footer - begin - self.staged_nested_header_footer_css = generate_nested_css(staged_header_footer_css) - rescue Sass::SyntaxError => err - errors.add(:base, "CSS for the top and bottom of your search results page: #{err}") - end - end - def language_valid errors.add(:base, "Locale must be valid") unless Language.exists?(code: self.locale) end - def generate_nested_css(css) - Renderers::CssToNestedCss.new('.header-footer', css).render if css.present? - end - - def validate_staged_header_footer - return unless is_validate_staged_header_footer - validate_header_results = validate_html staged_header - if validate_header_results[:has_malformed_html] - errors.add(:base, malformed_html_error_message(:top)) - end - - if validate_header_results[:has_banned_elements] - errors.add(:base, "HTML to customize the top of your search results page must not contain #{BANNED_HTML_ELEMENTS_FROM_HEADER_AND_FOOTER.join(', ')} elements.") - end - - if validate_header_results[:has_banned_attributes] - errors.add(:base, "HTML to customize the top of your search results page must not contain the onload attribute.") - end - - validate_footer_results = validate_html staged_footer - if validate_footer_results[:has_malformed_html] - errors.add(:base, malformed_html_error_message(:bottom)) - end - - if validate_footer_results[:has_banned_elements] - errors.add(:base, "HTML to customize the bottom of your search results page must not contain #{BANNED_HTML_ELEMENTS_FROM_HEADER_AND_FOOTER.join(', ')} elements.") - end - - if validate_footer_results[:has_banned_attributes] - errors.add(:base, "HTML to customize the bottom of your search results page must not contain the onload attribute.") - end - end - def html_columns_cannot_be_malformed %i(external_tracking_code footer_fragment).each do |field_name_symbol| value = self.send field_name_symbol @@ -827,45 +716,24 @@ def validate_html(html) validate_html_results end - def malformed_html_error_message(field_name) - sea = Rails.application.secrets.organization[:support_email_address] - email_link = %Q{#{sea}} - "HTML to customize the #{field_name} of your search results is invalid. Click on the validate link below or email us at #{email_link}".html_safe - end - - def sanitize_html(html) - unless html.blank? - doc = Nokogiri::HTML::DocumentFragment.parse html - doc.css("#{BANNED_HTML_ELEMENTS_FROM_HEADER_AND_FOOTER.join(',')}").each(&:remove) - doc.to_html - end - end - def update_error_keys swap_error_key(:"rss_feeds.base", :base) swap_error_key(:"site_domains.domain", :domain) swap_error_key(:"connections.connected_affiliate_id", :related_site_handle) swap_error_key(:"connections.label", :related_site_label) - swap_error_key(:staged_page_background_image_file_size, :page_background_image_file_size) - swap_error_key(:staged_header_image_file_size, :header_image_file_size) - end - - def previous_fields - @previous_fields ||= previous_fields_json.blank? ? {} : JSON.parse(previous_fields_json, :symbolize_names => true) end def live_fields @live_fields ||= live_fields_json.blank? ? {} : JSON.parse(live_fields_json, :symbolize_names => true) end + # deprecated - legacy SERP def staged_fields @staged_fields ||= staged_fields_json.blank? ? {} : JSON.parse(staged_fields_json, :symbolize_names => true) end def set_json_fields - self.previous_fields_json = ActiveSupport::OrderedHash[previous_fields.sort].to_json self.live_fields_json = ActiveSupport::OrderedHash[live_fields.sort].to_json - self.staged_fields_json = ActiveSupport::OrderedHash[staged_fields.sort].to_json end def load_css_properties @@ -891,18 +759,9 @@ def set_api_access_key self.api_access_key = Digest::SHA256.base64digest("#{name}:#{Time.current.to_i}:#{rand}").tr('+/', '-_') end - def sanitize_staged_header_footer - self.staged_header = strip_comments(staged_header) unless staged_header.blank? - self.staged_footer = strip_comments(staged_footer) unless staged_footer.blank? - end - - def set_is_validate_staged_header_footer(attributes) - self.is_validate_staged_header_footer = attributes[:staged_uses_managed_header_footer] == '0' - end - def generate_look_and_feel_css renderer = Renderers::AffiliateCss.new(build_css_hash) - self.look_and_feel_css = renderer.render_desktop_css + self.look_and_feel_css = renderer.render_desktop_css # legacy SERP self.mobile_look_and_feel_css = renderer.render_mobile_css end diff --git a/app/models/email_template.rb b/app/models/email_template.rb index d84072aa0b..1c059f20b5 100644 --- a/app/models/email_template.rb +++ b/app/models/email_template.rb @@ -5,8 +5,6 @@ class EmailTemplate < ApplicationRecord validates_uniqueness_of :name, case_sensitive: false DEFAULT_SUBJECT_HASH = { - affiliate_header_footer_change: '[Search.gov] Your header and footer '\ - 'for <%= @affiliate.display_name %> changed', affiliate_monthly_report: '[Search.gov] Monthly Report for '\ '<%= Date::MONTHNAMES[@user_monthly_report.report_date.month.to_i] %>'\ diff --git a/app/views/layouts/searches.html.haml b/app/views/layouts/searches.html.haml index b8a14aa585..90fd2cc89d 100644 --- a/app/views/layouts/searches.html.haml +++ b/app/views/layouts/searches.html.haml @@ -15,11 +15,10 @@ = stylesheet_link_tag 'searches_ie7' = stylesheet_link_tag "#{@affiliate.external_css_url}" unless @affiliate.external_css_url.blank? %title= @page_title - %body{ :class => render_affiliate_body_class(@affiliate), :style => render_affiliate_body_style(@affiliate) } + %body #skiplink %a{:href => "#main_content"} Skip to Main Content #container - = render_affiliate_header(@affiliate) #search %h1 Search - unless @affiliate.connections.blank? @@ -29,7 +28,6 @@ = yield #usasearch_footer_container %a#usasearch_footer_button{ title: t(:show_footer) } ▼ - = render_affiliate_footer(@affiliate) - if @affiliate.is_sayt_enabled? = javascript_tag "var usagov_sayt_url = \"#{sayt_url(aid: @affiliate.id, extras: true)}&\";" diff --git a/app/views/sites/header_and_footers/_advanced_mode_action_bar_items.html.haml b/app/views/sites/header_and_footers/_advanced_mode_action_bar_items.html.haml deleted file mode 100644 index fa4bed6fb1..0000000000 --- a/app/views/sites/header_and_footers/_advanced_mode_action_bar_items.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -%li= link_to 'Switch to Simple Mode', edit_site_header_and_footer_path(@site, mode: 'simple') -%li - .btn-group - = save_for_preview_button f, @site - = button_tag class: 'btn dropdown-toggle', data: { toggle: 'dropdown' }, - disabled: (!@site.has_staged_content? && !@site.uses_managed_header_footer?), - id: 'header-footer-dropdown-button' do - %span.caret - .description See Other Options - %ul.dropdown-menu - %li= make_live_button(f, @site) - %li= f.submit('Cancel Changes', class: 'btn-flat submit') if @site.has_staged_content? - diff --git a/app/views/sites/header_and_footers/_advanced_mode_form.html.haml b/app/views/sites/header_and_footers/_advanced_mode_form.html.haml deleted file mode 100644 index 2ae0f6ce34..0000000000 --- a/app/views/sites/header_and_footers/_advanced_mode_form.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -= f.label :staged_header_footer_css, 'CSS to customize the top and bottom of your search results page.' -= f.text_area :staged_header_footer_css, rows: 10 - -%fieldset - = f.label :staged_header, 'HTML to customize the top of your search results page.' - = f.text_area :staged_header, rows: 10 - .help-block= link_to 'Validate the top of your search results page.', 'http://validator.w3.org/nu/', id: 'validate-header', data: { source_selector: '#site_staged_header' } - -%fieldset - = f.label :staged_footer, 'HTML to customize the bottom of your search results page.' - = f.text_area :staged_footer, rows: 10 - .help-block= link_to 'Validate the bottom of your search results page.', 'http://validator.w3.org/nu/', id: 'validate-footer', data: { source_selector: '#site_staged_footer' } diff --git a/app/views/sites/header_and_footers/_simple_mode_form.html.haml b/app/views/sites/header_and_footers/_form.html.haml similarity index 100% rename from app/views/sites/header_and_footers/_simple_mode_form.html.haml rename to app/views/sites/header_and_footers/_form.html.haml diff --git a/app/views/sites/header_and_footers/_simple_mode_action_bar_items.html.haml b/app/views/sites/header_and_footers/_simple_mode_action_bar_items.html.haml deleted file mode 100644 index 3183376554..0000000000 --- a/app/views/sites/header_and_footers/_simple_mode_action_bar_items.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- unless @site.force_mobile_format? - %li= link_to 'Switch to Advanced Mode', edit_site_header_and_footer_path(@site, mode: 'advanced') -%li= save_header_footer_button f, @site diff --git a/app/views/sites/header_and_footers/_validate_html_form.html.haml b/app/views/sites/header_and_footers/_validate_html_form.html.haml deleted file mode 100644 index 9934d176b0..0000000000 --- a/app/views/sites/header_and_footers/_validate_html_form.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -= form_tag 'http://validator.w3.org/nu/', id: 'validator-form', method: :post, multipart: true, target: '_blank' do - = hidden_field_tag :showsource, '1' - = hidden_field_tag :parser, 'html4tr' - = text_area_tag :content - = submit_tag 'Validate' diff --git a/app/views/sites/header_and_footers/edit.html.haml b/app/views/sites/header_and_footers/edit.html.haml index d1001caa28..9bda583dfc 100644 --- a/app/views/sites/header_and_footers/edit.html.haml +++ b/app/views/sites/header_and_footers/edit.html.haml @@ -1,14 +1,12 @@ = content_for_site_page_title @site, 'Header & Footer' = form_for @site, as: :site, url: site_header_and_footer_path(@site), - html: { class: 'form', id: 'edit-header-and-footer' } do |f| + html: { class: 'form', id: 'edit-header-and-footer' } do |form| .sub-nav-heading %h2 Header & Footer .action-bar %ul = list_item_with_link_to_current_help_page - = render partial: "#{@mode}_mode_action_bar_items", locals: { f: f } + %li= form.submit 'Save', class: 'btn submit disabled', disabled: true = render_flash_message = render_error_messages(@site) - = hidden_field_tag :mode, @mode - = render partial: "#{@mode}_mode_form", locals: { f: f } -= render partial: 'validate_html_form' if @mode == 'advanced' + = render partial: 'form', locals: { f: form } diff --git a/db/email_templates/affiliate_header_footer_change.html.erb b/db/email_templates/affiliate_header_footer_change.html.erb deleted file mode 100644 index d63507455b..0000000000 --- a/db/email_templates/affiliate_header_footer_change.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -You've changed the header or footer for <%= @affiliate.display_name %> so we're sending you this email for your records. - -To revert to the previous version of your header or footer, copy the code below. Paste it into the boxes at Admin Center > YourSite > Manage Display > Header & Footer. - -<%= site_url(@affiliate) %> - -Search.gov Team -General Services Administration -202-969-7426 | search@support.digitalgov.gov -https://search.gov - -++++++++++ - -YOUR PREVIOUS HEADER -<%= @affiliate.previous_header.html_safe unless @affiliate.previous_header.blank? %> - -YOUR PREVIOUS FOOTER - -<%= @affiliate.previous_footer.html_safe unless @affiliate.previous_footer.blank? %> - -++++++++++ - -YOUR CURRENT HEADER - -<%= @affiliate.header.html_safe %> - -YOUR CURRENT FOOTER - -<%= @affiliate.footer.html_safe %> - -++++++++++ diff --git a/features/admin_center_manage_display.feature b/features/admin_center_manage_display.feature index b15edb09b9..4ec4f4577d 100644 --- a/features/admin_center_manage_display.feature +++ b/features/admin_center_manage_display.feature @@ -376,8 +376,8 @@ Feature: Manage Display And I should not see an image with alt text "Logo" @javascript - Scenario: Editing Managed Header & Footer - Given the following legacy Affiliates exist: + Scenario: Editing Header & Footer + Given the following Affiliates exist: | display_name | name | contact_email | first_name | last_name | footer_fragment | | agency site | agency.gov | john@agency.gov | John | Bar | my HTML fragment | And affiliate "agency.gov" has the following document collections: @@ -389,7 +389,7 @@ Feature: Manage Display | Inactive news search | http://en.agency.gov/feed/News | false | 5 | false | And I am logged in with email "john@agency.gov" - When I am on agency.gov's mobile search page + When I am on agency.gov's search page Then I should not see "Browse site" When I go to the agency.gov's Header & Footer page @@ -432,14 +432,10 @@ Feature: Manage Display And the "Footer Link URL 1" field should contain "http://tos.agency.gov" When I am on agency.gov's search page - Then I should see a link to "News" with url for "http://news.agency.gov" - And I should see a link to "Blog" with url for "http://blog.agency.gov" - And I should see a link to "Contact" with url for "mailto:contact@agency.gov" + Then I should see a link to "Contact" with url for "mailto:contact@agency.gov" And I should see a link to "Terms of Service" with url for "http://tos.agency.gov" - - When I am on agency.gov's mobile search page And the page body should contain "mini_logo.png" - Then I should see "Office website of the Awesome Agency" + And I should see "Office website of the Awesome Agency" And I should see a left aligned menu button And I should see "my HTML fragment" within the mobile footer And I should not see "strong" within the mobile footer @@ -451,22 +447,18 @@ Feature: Manage Display Then I should see a link to "Contact" with url for "mailto:contact@agency.gov" Then I should see a link to "Terms of Service" with url for "http://tos.agency.gov" - When I am on agency.gov's "Inactive site search" mobile site search page + When I am on agency.gov's "Inactive site search" docs search page And I press "Browse site" Then I should find "News" in the main menu Then I should see a link to "News" with url for "http://news.agency.gov" Then I should see a link to "Blog" with url for "http://blog.agency.gov" - When I am on agency.gov's "Inactive news search" mobile news search page + When I am on agency.gov's "Inactive news search" news search page And I press "Browse site" Then I should find "News" in the main menu Then I should see a link to "News" with url for "http://news.agency.gov" Then I should see a link to "Blog" with url for "http://blog.agency.gov" - When I go to the agency.gov's Header & Footer page - And I follow "Switch to Advanced Mode" - Then I should see "CSS to customize the top and bottom of your search results page" - When I go to the agency.gov's Header & Footer page And I check "Mark Header Tagline Logo for Deletion" And I submit the form by pressing "Save" @@ -479,12 +471,11 @@ Feature: Manage Display And I should not see an image with alt text "Header Tagline Logo" @javascript - Scenario: Error when Editing Managed Header & Footer - Given the following legacy Affiliates exist: + Scenario: Error when Editing Header & Footer + Given the following Affiliates exist: | display_name | name | contact_email | first_name | last_name | | agency site | agency.gov | john@agency.gov | John | Bar | And I am logged in with email "john@agency.gov" - And no emails have been sent When I go to the agency.gov's Header & Footer page And I fill in the following: | Header Link Title 0 | News | @@ -493,65 +484,6 @@ Feature: Manage Display Then I should see "Header link URL can't be blank" Then I should see "Footer link title can't be blank" - @javascript - Scenario: Editing Custom Header & Footer - Given the following legacy Affiliates exist: - | display_name | name | contact_email | first_name | last_name | staged_header | - | agency site | agency.gov | john@agency.gov | John | Bar | header | - And I am logged in with email "john@agency.gov" - And no emails have been sent - When I go to the agency.gov's Header & Footer page - And I follow "Switch to Advanced Mode" - And I fill in the following: - | CSS to customize the top and bottom of your search results page | .staged { color: blue } | - | HTML to customize the top of your search results page | Staged Header | - | HTML to customize the bottom of your search results page | Staged Footer | - And I submit the form by pressing "Save for Preview" - Then I should see "You have saved header and footer changes for preview" - And the "CSS to customize the top and bottom of your search results page" field should contain ".staged \{ color: blue \}" - And the "HTML to customize the top of your search results page" field should contain "Staged Header" - And the "HTML to customize the bottom of your search results page" field should contain "Staged Footer" - - When I access the dropdown button group within the "Header & Footer form" - And I press "Make Live" - Then I should see "You have saved header and footer changes to your live site" - - When "john@agency.gov" opens the email - Then I should see "Your header and footer for agency site changed" in the email subject - And I should see "You've changed the header or footer for agency site so we're sending you this email for your records" in the email body - And I should see "Staged Header" in the email body - And I should see "Staged Footer" in the email body - - When I fill in the following: - | CSS to customize the top and bottom of your search results page | .staged { color: red } | - And I submit the form by pressing "Save for Preview" - Then I should see "You have saved header and footer changes for preview" - - When I access the dropdown button group within the "Header & Footer form" - And I press "Cancel Changes" - Then I should see "You have cancelled header and footer changes" - - When I follow "Switch to Simple Mode" - Then I should see "Header Links" - - @javascript - Scenario: Error when Editing Custom Header & Footer - Given the following legacy Affiliates exist: - | display_name | name | contact_email | first_name | last_name | - | agency site | agency.gov | john@agency.gov | John | Bar | - And I am logged in with email "john@agency.gov" - And no emails have been sent - When I go to the agency.gov's Header & Footer page - And I follow "Switch to Advanced Mode" - And I fill in the following: - | CSS to customize the top and bottom of your search results page | .staged { color: | - And I submit the form by pressing "Save for Preview" - Then I should see "Invalid CSS" - - When I access the dropdown button group within the "Header & Footer form" - And I press "Make Live" - Then I should see "Invalid CSS" - @javascript Scenario: Editing No Results Page Given the following Affiliates exist: diff --git a/features/legacy_search.feature b/features/legacy_search.feature index a30d45fe0c..3d6bf1b1a6 100644 --- a/features/legacy_search.feature +++ b/features/legacy_search.feature @@ -996,15 +996,6 @@ Feature: Legacy Search And I follow "Everything" in the left column Then I should see "www.usa.gov/" - Scenario: Visiting affiliate with strictui parameters - Given the following legacy Affiliates exist: - | display_name | name | contact_email | first_name | last_name | external_css_url | header | footer | - | aff site | aff.gov | aff@bar.gov | John | Bar | http://cdn.aff.gov/external.css |

header

|

footer

| - When I go to aff.gov's strictui search page - Then I should not see the page with external affiliate stylesheet "http://cdn.aff.gov/external.css" - And I should not see tainted SERP header - And I should not see tainted SERP footer - Scenario: Affiliate search on affiliate with connections Given the following legacy Affiliates exist: | display_name | name | contact_email | first_name | last_name | domains | diff --git a/features/searches.feature b/features/searches.feature index abe659a27e..afbe36d52c 100644 --- a/features/searches.feature +++ b/features/searches.feature @@ -376,15 +376,6 @@ Feature: Search Then I should see at least "1" web search results And every result URL should match "search.gov/blog" - Scenario: Visiting affiliate with strictui parameters - Given the following Affiliates exist: - | display_name | name | contact_email | first_name | last_name | external_css_url | header | footer | - | aff site | aff.gov | aff@bar.gov | John | Bar | http://cdn.aff.gov/external.css |

header

|

footer

| - When I go to aff.gov's strictui search page - Then I should not see the page with external affiliate stylesheet "http://cdn.aff.gov/external.css" - And I should not see tainted SERP header - And I should not see tainted SERP footer - Scenario: Affiliate search on affiliate with connections Given the following Affiliates exist: | display_name | name | contact_email | first_name | last_name | domains | diff --git a/features/step_definitions/within_steps.rb b/features/step_definitions/within_steps.rb index 4585b952f4..875952b46c 100644 --- a/features/step_definitions/within_steps.rb +++ b/features/step_definitions/within_steps.rb @@ -37,8 +37,6 @@ 'in the previously crawled URL list': '.crawled-url-list', 'in the indexed documents section': '#indexed_documents', 'in the medline govbox': '.medline', # legacy SERP - 'in the SERP header': '#header', - 'in the SERP footer': '#usasearch_footer', 'in the page content': '.content', 'in the API TOS section': '.api.tos', 'in the registration form': 'form#new_user', diff --git a/features/support/paths.rb b/features/support/paths.rb index 72c61401fe..d8721e46bf 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -20,8 +20,6 @@ def path_to(page_name) search_path(:affiliate => $1, :m => 'override') when /^(.*)'s advanced search page$/ advanced_search_path(:affiliate => $1) - when /^(.*)'s strictui search page$/ - search_path(:affiliate => $1, :strictui => "1") when /^(.*)'s search page with unsanitized "([^\"]*)" query$/ search_path(:affiliate => $1, :query => "#{$2}") when /^(.*)'s search page with site limited to "([^\"]*)"$/ diff --git a/features/vcr_cassettes/Manage_Display/Editing_Managed_Header_Footer.yml b/features/vcr_cassettes/Manage_Display/Editing_Header_Footer.yml similarity index 51% rename from features/vcr_cassettes/Manage_Display/Editing_Managed_Header_Footer.yml rename to features/vcr_cassettes/Manage_Display/Editing_Header_Footer.yml index e47ab49d6f..454161d8b4 100644 --- a/features/vcr_cassettes/Manage_Display/Editing_Managed_Header_Footer.yml +++ b/features/vcr_cassettes/Manage_Display/Editing_Header_Footer.yml @@ -2,28 +2,18 @@ http_interactions: - request: method: put - uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1520342858/original/mini_logo.png + uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1619549241/original/mini_logo.png body: encoding: ASCII-8BIT string: !binary |- - iVBORw0KGgoAAAANSUhEUgAAABYAAAAZCAQAAACf6xZlAAAAGXRFWHRTb2Z0 - d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAZFJREFUGBmNwU1oDQAcAPD/ - PlrKPmSzw9R2mraDj7JWWsqSJZMhJDsoivemXJgoioOGpu1gB60cdqF2WUk4 - rRltlFLKDoRpBzVqeW8bZfv5KLX1ZtvvF7EsrquL5bHfTwdiafJ1oU+eW7E4 - DUZNabVKr1T8n0LdGFCp3keTDsb/aDTmmxYrdZo1rCoWplgPHiq3zVvftSqw - IxZil8++OqpQF4ZVqfXG1chkixn3lWrwybRWBTrNGFAUmfQbkacdgyrVe2/K - WTmRSQUSGtGmyG30q4yFOWXWGnd9kO25lBOyYj4VEvapUeaJp7KM61CLpsjk - mX8m1MmV0u4IymI+zbqdUWyd7ZoUR2iTVq7PqNyYzw33/DDhmrL4y16cVoM9 - kUmpy76Y1qEkwgrjXkZ4Z0RSt8faVcVc8l2UlnJengfSElokbbXTC3+8sinm - slYvXtusWhJD8Zsch1xQHZkcljJptY3SjsVS3DHkkh4lsThZzrkpgfWxFFek - ZTuJR5picQbN2CBX0nFFsTjNUsbsjgX9AtZabdMhQhzuAAAAAElFTkSuQmCC + iVBORw0KGgoAAAANSUhEUgAAABYAAAAZCAQAAACf6xZlAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAZFJREFUGBmNwU1oDQAcAPD/PlrKPmSzw9R2mraDj7JWWsqSJZMhJDsoivemXJgoioOGpu1gB60cdqF2WUk4rRltlFLKDoRpBzVqeW8bZfv5KLX1ZtvvF7EsrquL5bHfTwdiafJ1oU+eW7E4DUZNabVKr1T8n0LdGFCp3keTDsb/aDTmmxYrdZo1rCoWplgPHiq3zVvftSqwIxZil8++OqpQF4ZVqfXG1chkixn3lWrwybRWBTrNGFAUmfQbkacdgyrVe2/KWTmRSQUSGtGmyG30q4yFOWXWGnd9kO25lBOyYj4VEvapUeaJp7KM61CLpsjkmX8m1MmV0u4IymI+zbqdUWyd7ZoUR2iTVq7PqNyYzw33/DDhmrL4y16cVoM9kUmpy76Y1qEkwgrjXkZ4Z0RSt8faVcVc8l2UlnJengfSElokbbXTC3+8sinmslYvXtusWhJD8Zsch1xQHZkcljJptY3SjsVS3DHkkh4lsThZzrkpgfWxFFekZTuJR5picQbN2CBX0nFFsTjNUsbsjgX9AtZabdMhQhzuAAAAAElFTkSuQmCC headers: Content-Type: - image/png Accept-Encoding: - '' User-Agent: - - aws-sdk-ruby2/2.10.125 ruby/2.3.5 x86_64-darwin15 resources + - aws-sdk-ruby2/2.11.632 ruby/2.6.6 x86_64-darwin19 resources X-Amz-Acl: - public-read Expect: @@ -31,13 +21,15 @@ http_interactions: Content-Md5: - 6uH1VCcGpag797A21L81cg== X-Amz-Date: - - 20180306T132738Z + - 20210427T184721Z + Host: + - ".s3.amazonaws.com" X-Amz-Content-Sha256: - bad02614f4d0c320d62b980725576149477c9b7de73ba5aa082711dc82d3b32e Authorization: - - AWS4-HMAC-SHA256 Credential=/20180306//s3/aws4_request, + - AWS4-HMAC-SHA256 Credential=/20210427//s3/aws4_request, SignedHeaders=content-md5;content-type;host;x-amz-acl;x-amz-content-sha256;x-amz-date, - Signature=814635e113156c8a64b1ae7618a29f73ce6ba8e7f8b8303de1d7f33add4011ac + Signature=662837bfdaf12e969b4c4eae66bb280c87344fb022db47d8db7751c4529144f2 Content-Length: - '495' Accept: @@ -48,11 +40,11 @@ http_interactions: message: OK headers: X-Amz-Id-2: - - MyddRq/a7pcrqkhz9zTStgUOi9oBoofZgz++L5ZubhE8cg16XzVV4xoe5byBKJOkjQk+hcUnJ1k= + - kcXuVIiyvfAh0a0l56B8BoBp4124CIifOqesgb7FAKczOIrsPYfzRiMzCbGgyb7nxlK9utLbBI4= X-Amz-Request-Id: - - DF32DC26363DC530 + - XET1F28XYGS75BQW Date: - - Tue, 06 Mar 2018 13:27:43 GMT + - Tue, 27 Apr 2021 18:47:23 GMT Etag: - '"eae1f5542706a5a83bf7b036d4bf3572"' Content-Length: @@ -62,51 +54,38 @@ http_interactions: body: encoding: UTF-8 string: '' - http_version: - recorded_at: Tue, 06 Mar 2018 13:27:42 GMT + http_version: + recorded_at: Tue, 27 Apr 2021 18:47:22 GMT - request: method: put - uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1520342858/large/mini_logo.png + uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1619549241/large/mini_logo.png body: encoding: ASCII-8BIT string: !binary |- - iVBORw0KGgoAAAANSUhEUgAAABYAAAAZCAQAAACf6xZlAAAABGdBTUEAALGP - C/xhBQAAAAJiS0dEAP+Hj8y/AAAAB3RJTUUH4gMHBRsmMN/ezAAAAAFvck5U - Ac+id5oAAAG2SURBVDjLjdFPaA5wGAfw593Wmmwj86em5uLVVkJZK6SMLJn8 - C6kdlAPblAPeohw4aGi1HSxpcXBA7bKSf6f5V4aUWnEgTDuoTeF9Z8h8XCbt - 9W723H6/5/N7+j19I6ZUzlg1NRm2+2nHVGCxDnQrdO5/tE6/r1Jm6pKeDJbq - xD1Jtd4ZtnNiWm/AF82ma/dLr8qJYJnLuKXCGq98k1JifW660Qcf7VGqA70q - 1XjhVC66wqjr5qrz3oiUEu1G3TMjF+7xUqFWPJBU642vjsjPRRegUT1azHAB - PZITrXbAL3Nc9Vaex9L2Sfw7r9E21crd91DCoDY12DLeFURExJVYOXb+HPWR - H0UxGgsj4mn21AadDiuzyDpblEVokVGhW7+CbHzWNd99clr52M1WHFSNzbnW - muuEISPazI5QZNCzCK+91KTTHa1ZYSt2XEbaUYVuyGjUrMlqGzwBzy0b/2C+ - LvRZrkoTHkVEyLfLMVW5vrRb2rBZlsrYO76XyMEvRVXcjGQcSgxNiiUiFfPi - VZyPJYm+mLyclJFnP25n5/cnwb+1NqbF4rgYefEj7v5vcoO0AZtyd38D5zlN - AMd7TrMAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTgtMDMtMDZUMjE6Mjc6Mzgr - MDg6MDDNYUh5AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE4LTAzLTA2VDIxOjI3 - OjM4KzA4OjAwvDzwxQAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFk - eXHJZTwAAAAASUVORK5CYII= + iVBORw0KGgoAAAANSUhEUgAAABYAAAAZCAQAAACf6xZlAAAABGdBTUEAALGPC/xhBQAAAAJiS0dEAP+Hj8y/AAAAB3RJTUUH5QQbEi8VmKb9VwAAAAFvck5UAc+id5oAAAG2SURBVDjLjdFPaA5wGAfw593Wmmwj86em5uLVVkJZK6SMLJn8C6kdlAPblAPeohw4aGi1HSxpcXBA7bKSf6f5V4aUWnEgTDuoTeF9Z8h8XCbt9W723H6/5/N7+j19I6ZUzlg1NRm2+2nHVGCxDnQrdO5/tE6/r1Jm6pKeDJbqxD1Jtd4ZtnNiWm/AF82ma/dLr8qJYJnLuKXCGq98k1JifW660Qcf7VGqA70q1XjhVC66wqjr5qrz3oiUEu1G3TMjF+7xUqFWPJBU642vjsjPRRegUT1azHABPZITrXbAL3Nc9Vaex9L2Sfw7r9E21crd91DCoDY12DLeFURExJVYOXb+HPWRH0UxGgsj4mn21AadDiuzyDpblEVokVGhW7+CbHzWNd99clr52M1WHFSNzbnWmuuEISPazI5QZNCzCK+91KTTHa1ZYSt2XEbaUYVuyGjUrMlqGzwBzy0b/2C+LvRZrkoTHkVEyLfLMVW5vrRb2rBZlsrYO76XyMEvRVXcjGQcSgxNiiUiFfPiVZyPJYm+mLyclJFnP25n5/cnwb+1NqbF4rgYefEj7v5vcoO0AZtyd38D5zlNAMd7TrMAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDQtMjdUMTg6NDc6MjErMDA6MDCqQjFLAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTA0LTI3VDE4OjQ3OjIxKzAwOjAw2x+J9wAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAASUVORK5CYII= headers: Content-Type: - image/png Accept-Encoding: - '' User-Agent: - - aws-sdk-ruby2/2.10.125 ruby/2.3.5 x86_64-darwin15 resources + - aws-sdk-ruby2/2.11.632 ruby/2.6.6 x86_64-darwin19 resources X-Amz-Acl: - public-read Expect: - 100-continue Content-Md5: - - lBperALluFRUN31EIykwww== + - pkTGqBSS/KlhpsctHmwudg== X-Amz-Date: - - 20180306T132742Z + - 20210427T184722Z + Host: + - ".s3.amazonaws.com" X-Amz-Content-Sha256: - - 2e3b9f51c5ccff4f387d11b05d5e5ca3fafa05ab68df066d8f5a4e0f3e1dc8fa + - 61138c0a5c7f78ccd2e06be854b48295ff3affe67b1bb04560e4003cf7652b6d Authorization: - - AWS4-HMAC-SHA256 Credential=/20180306//s3/aws4_request, + - AWS4-HMAC-SHA256 Credential=/20210427//s3/aws4_request, SignedHeaders=content-md5;content-type;host;x-amz-acl;x-amz-content-sha256;x-amz-date, - Signature=13c41c5eeeb4707e0e2c373d6b239f78cdacff6231c2dc66eca736dbe4a1f189 + Signature=93a4ee7ff53e58ce24b613db88ecc3a4074f0fb42d210278eb0581bcf1f17f0a Content-Length: - '692' Accept: @@ -117,13 +96,13 @@ http_interactions: message: OK headers: X-Amz-Id-2: - - oIfiPGlcAqvOtCtadNKe+bbfrwOEEdPO2SFX5jUMZ2I53dyE4yGWOaWUIlAXx9uFdIMlWXsfnhE= + - LSFrgBg1yCO4laeFzRdBZMKl86RFi5+XyvphnNFBKs8HtWjqZMWi4j/asKdBHqUNDRSWCm45mj8= X-Amz-Request-Id: - - 1DA28D97ACD52BE2 + - XETDXH5E5J4KD18A Date: - - Tue, 06 Mar 2018 13:27:45 GMT + - Tue, 27 Apr 2021 18:47:23 GMT Etag: - - '"941a5eac02e5b85454377d44232930c3"' + - '"a644c6a81492fca961a6c72d1e6c2e76"' Content-Length: - '0' Server: @@ -131,13 +110,13 @@ http_interactions: body: encoding: UTF-8 string: '' - http_version: - recorded_at: Tue, 06 Mar 2018 13:27:44 GMT + http_version: + recorded_at: Tue, 27 Apr 2021 18:47:22 GMT - request: method: head - uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1520342858/original/mini_logo.png + uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1619549241/original/mini_logo.png body: - encoding: ASCII-8BIT + encoding: UTF-8 string: '' headers: Content-Type: @@ -145,14 +124,16 @@ http_interactions: Accept-Encoding: - '' User-Agent: - - aws-sdk-ruby2/2.10.125 ruby/2.3.5 x86_64-darwin15 resources + - aws-sdk-ruby2/2.11.632 ruby/2.6.6 x86_64-darwin19 resources X-Amz-Date: - - 20180306T132749Z + - 20210427T184723Z + Host: + - ".s3.amazonaws.com" X-Amz-Content-Sha256: - e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Authorization: - - AWS4-HMAC-SHA256 Credential=/20180306//s3/aws4_request, - SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=1c2aec82e8d294c6fd8c1ca4a6e7256b30629066ac9bede21776ec4030354ce9 + - AWS4-HMAC-SHA256 Credential=/20210427//s3/aws4_request, + SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=d10c1513d1d1d20b6d904ea07c19bada58bbd72355c1e152df92e7a562049151 Content-Length: - '0' Accept: @@ -163,13 +144,13 @@ http_interactions: message: OK headers: X-Amz-Id-2: - - 5x8Kp7nt+VM4ikXeuTOCMcLOV8AzL5Wlre+FW6dcovh35dvins3zxq2g7PgJON93lvKzXLSB4eg= + - 4gJxUL5ut7jDHoTeZP4fedrCqn8krmi5f+hwmuNjiiRvZ93jIW2JuYpbyiptmq+e6s/ZBzD3yok= X-Amz-Request-Id: - - 1827683BB30000BB + - NH97EC6RQWMGHNN6 Date: - - Tue, 06 Mar 2018 13:27:51 GMT + - Tue, 27 Apr 2021 18:47:24 GMT Last-Modified: - - Tue, 06 Mar 2018 13:27:43 GMT + - Tue, 27 Apr 2021 18:47:23 GMT Etag: - '"eae1f5542706a5a83bf7b036d4bf3572"' Accept-Ranges: @@ -183,13 +164,13 @@ http_interactions: body: encoding: UTF-8 string: '' - http_version: - recorded_at: Tue, 06 Mar 2018 13:27:50 GMT + http_version: + recorded_at: Tue, 27 Apr 2021 18:47:23 GMT - request: method: head - uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1520342858/large/mini_logo.png + uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1619549241/large/mini_logo.png body: - encoding: ASCII-8BIT + encoding: UTF-8 string: '' headers: Content-Type: @@ -197,14 +178,16 @@ http_interactions: Accept-Encoding: - '' User-Agent: - - aws-sdk-ruby2/2.10.125 ruby/2.3.5 x86_64-darwin15 resources + - aws-sdk-ruby2/2.11.632 ruby/2.6.6 x86_64-darwin19 resources X-Amz-Date: - - 20180306T132750Z + - 20210427T184723Z + Host: + - ".s3.amazonaws.com" X-Amz-Content-Sha256: - e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Authorization: - - AWS4-HMAC-SHA256 Credential=/20180306//s3/aws4_request, - SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=3d63f31fd39aad63e421e11e88062fa5ef5147b907f7b24dd93dfe18279efbab + - AWS4-HMAC-SHA256 Credential=/20210427//s3/aws4_request, + SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=1b78175fddd25345f06dc3533bc7b7aad150b0256bf77534daf286d3af2f0341 Content-Length: - '0' Accept: @@ -215,15 +198,15 @@ http_interactions: message: OK headers: X-Amz-Id-2: - - UvpQ2BYsZx/IWCNzpIw6nJRFGaW0wdXajs2HdYJw0FFuJnWXag0wqb3hFg3R09rc/FVfvYslVsA= + - oSGgwQdFUGAND1e2JPdF+LgjMOV0VPT6fi/WDvJYLqtx4XRERvkSLisvPe6n3BKkRJUDinKP8y0= X-Amz-Request-Id: - - 944162AF33978189 + - 37XFAZFCRZKRSYB9 Date: - - Tue, 06 Mar 2018 13:27:52 GMT + - Tue, 27 Apr 2021 18:47:25 GMT Last-Modified: - - Tue, 06 Mar 2018 13:27:45 GMT + - Tue, 27 Apr 2021 18:47:23 GMT Etag: - - '"941a5eac02e5b85454377d44232930c3"' + - '"a644c6a81492fca961a6c72d1e6c2e76"' Accept-Ranges: - bytes Content-Type: @@ -235,13 +218,13 @@ http_interactions: body: encoding: UTF-8 string: '' - http_version: - recorded_at: Tue, 06 Mar 2018 13:27:52 GMT + http_version: + recorded_at: Tue, 27 Apr 2021 18:47:24 GMT - request: method: delete - uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1520342858/original/mini_logo.png + uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1619549241/original/mini_logo.png body: - encoding: ASCII-8BIT + encoding: UTF-8 string: '' headers: Content-Type: @@ -249,14 +232,16 @@ http_interactions: Accept-Encoding: - '' User-Agent: - - aws-sdk-ruby2/2.10.125 ruby/2.3.5 x86_64-darwin15 resources + - aws-sdk-ruby2/2.11.632 ruby/2.6.6 x86_64-darwin19 resources X-Amz-Date: - - 20180306T132752Z + - 20210427T184724Z + Host: + - ".s3.amazonaws.com" X-Amz-Content-Sha256: - e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Authorization: - - AWS4-HMAC-SHA256 Credential=/20180306//s3/aws4_request, - SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=5d5c0706d840fc17beacc7698623ddf5804d6df7f57af3e21adbe9a69c743191 + - AWS4-HMAC-SHA256 Credential=/20210427//s3/aws4_request, + SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=4e13c0b389eb9766f77fad0bc759a0b3d90951e6605b416977de2cee444c0788 Content-Length: - '0' Accept: @@ -267,23 +252,23 @@ http_interactions: message: No Content headers: X-Amz-Id-2: - - '08vJk8AT9DMQVvUBS4TO0vyi2xPZLHSnl6YXBTl1JV8jc7jjeggFt661r067njmulHDUB57WTHw=' + - zsPFh8Fa4dCkHgC1R3Ys6Uge712q+9SvAwC68+RVQviJZmpXGVodzro3kt92ZmKNIlbV8fZDYNQ= X-Amz-Request-Id: - - D82FEFD75AF8D8A4 + - 37XA547B0WJZACZH Date: - - Tue, 06 Mar 2018 13:27:55 GMT + - Tue, 27 Apr 2021 18:47:25 GMT Server: - AmazonS3 body: encoding: UTF-8 string: '' - http_version: - recorded_at: Tue, 06 Mar 2018 13:27:54 GMT + http_version: + recorded_at: Tue, 27 Apr 2021 18:47:24 GMT - request: method: delete - uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1520342858/large/mini_logo.png + uri: https://.s3.amazonaws.com/test/site/1057602728/header_tagline_logo/1619549241/large/mini_logo.png body: - encoding: ASCII-8BIT + encoding: UTF-8 string: '' headers: Content-Type: @@ -291,14 +276,16 @@ http_interactions: Accept-Encoding: - '' User-Agent: - - aws-sdk-ruby2/2.10.125 ruby/2.3.5 x86_64-darwin15 resources + - aws-sdk-ruby2/2.11.632 ruby/2.6.6 x86_64-darwin19 resources X-Amz-Date: - - 20180306T132754Z + - 20210427T184724Z + Host: + - ".s3.amazonaws.com" X-Amz-Content-Sha256: - e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Authorization: - - AWS4-HMAC-SHA256 Credential=/20180306//s3/aws4_request, - SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=3356f184fecc81e3d732d9aa54ccba392038fb40d3162d4de22f99dc854470a4 + - AWS4-HMAC-SHA256 Credential=/20210427//s3/aws4_request, + SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=dcb13f111d518ba552f325b2833591e108d3770cdafbed745dbc5775dc62bdc2 Content-Length: - '0' Accept: @@ -309,16 +296,16 @@ http_interactions: message: No Content headers: X-Amz-Id-2: - - nrfPE3zqor8M/dwIFuzZZdFOx2NFfnnXUYEfZb0cxsBtOKnpYlwcGWZznRKWvlRT36enF4SuwRQ= + - FAO6JCn2aXRynXlWsPM5b/knnRsswM90aPbGfxgOetPcb+WQsa5+0Kz8s9bfNnJUe2nGilFEgBA= X-Amz-Request-Id: - - 55C7417C5F5299F2 + - 37X36XNJ906BDB8T Date: - - Tue, 06 Mar 2018 13:27:56 GMT + - Tue, 27 Apr 2021 18:47:25 GMT Server: - AmazonS3 body: encoding: UTF-8 string: '' - http_version: - recorded_at: Tue, 06 Mar 2018 13:27:55 GMT + http_version: + recorded_at: Tue, 27 Apr 2021 18:47:24 GMT recorded_with: VCR 4.0.0 diff --git a/lib/renderers/css_to_nested_css.rb b/lib/renderers/css_to_nested_css.rb deleted file mode 100644 index 23e046e8e0..0000000000 --- a/lib/renderers/css_to_nested_css.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Renderers - class CssToNestedCss - AT_RULES_TO_REJECT = %w(@charset @import).freeze - - def initialize(parent_selector, css) - @parent_selector = parent_selector - @css = css - end - - def render - ::Renderers::Sass.new(render_nested_sass).render - end - - private - - def render_nested_sass - sass_values = [@parent_selector] - original_sass_values = ::Sass::CSS.new(@css).render.split("\n") - original_sass_values.reject! { |value| value =~ /^(#{AT_RULES_TO_REJECT.join('|')})/ } - sass_values.push(original_sass_values.map { |value| " #{value}" }) - sass_values.join("\n") - end - end -end diff --git a/lib/xml_processor.rb b/lib/xml_processor.rb deleted file mode 100644 index 42144e4236..0000000000 --- a/lib/xml_processor.rb +++ /dev/null @@ -1,15 +0,0 @@ -module XmlProcessor - def strip_comments(xml) - doc = Nokogiri::HTML::DocumentFragment.parse xml - doc.children.each { |c| strip_comments_on_node(c) } - doc.to_html.strip - end - - private - def strip_comments_on_node(node) - node.remove and return if node.comment? - node.children.each do |c| - strip_comments_on_node c - end - end -end \ No newline at end of file diff --git a/spec/controllers/searches_controller_spec.rb b/spec/controllers/searches_controller_spec.rb index 5727e09dea..f03cb76061 100644 --- a/spec/controllers/searches_controller_spec.rb +++ b/spec/controllers/searches_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +# frozen_string_literal: true describe SearchesController do let(:affiliate) { affiliates(:usagov_affiliate) } @@ -230,14 +230,6 @@ expect(@page_title).to eq('thunder & lightning - Legacy Search Results') end - it 'should render the header in the response' do - expect(response.body).to match(/#{affiliate.header}/) - end - - it 'should render the footer in the response' do - expect(response.body).to match(/#{affiliate.footer}/) - end - it 'should set the sanitized query in Javascript' do expect(response.body).to include(%q{var original_query = "thunder & lightning"}) end diff --git a/spec/controllers/sites/sites_controller_spec.rb b/spec/controllers/sites/sites_controller_spec.rb index 2c2124f714..63f3845cc7 100644 --- a/spec/controllers/sites/sites_controller_spec.rb +++ b/spec/controllers/sites/sites_controller_spec.rb @@ -123,7 +123,6 @@ 'name' => 'newaff', 'site_domains_attributes' => { '0' => { 'domain' => 'http://www.brandnew.gov' } }).and_return(site) expect(site).to receive(:save).and_return(true) - expect(site).to receive(:push_staged_changes) expect(site).to receive(:assign_sitelink_generator_names!) autodiscoverer = double(SiteAutodiscoverer) diff --git a/spec/helpers/affiliate_helper_spec.rb b/spec/helpers/affiliate_helper_spec.rb index 1c88a6bfb1..37705c99d6 100644 --- a/spec/helpers/affiliate_helper_spec.rb +++ b/spec/helpers/affiliate_helper_spec.rb @@ -1,48 +1,6 @@ require 'spec_helper' describe AffiliateHelper do - describe '#render_managed_header' do - context 'when the affiliate has a header image and an exception occurs when trying to retrieve the image' do - let(:header_image) { double('header image') } - let(:affiliate) { mock_model(Affiliate, - css_property_hash: Affiliate::DEFAULT_CSS_PROPERTIES, - header_image_file_name: 'logo.gif', - header_image: header_image) } - - before do - expect(header_image).to receive(:url).and_raise - end - - specify { expect(helper.render_managed_header(affiliate)).not_to have_select(:img) } - end - end - - describe '#render_affiliate_body_style' do - context 'when an error occurs' do - let(:affiliate) { mock_model(Affiliate, css_property_hash: {}, page_background_image_file_name: 'bg.png') } - it 'should return only background-color' do - expect(helper).to receive(:render_affiliate_css_property_value).with({}, :page_background_color).and_return('#DDDDDD') - expect(affiliate).to receive(:page_background_image).and_raise(StandardError) - expect(helper.render_affiliate_body_style(affiliate)).to eq('background-color: #DDDDDD') - end - end - - context 'when the affiliate has a background image configured' do - let(:affiliate) do - mock_model(Affiliate, { - page_background_image_file_name: 'background.png', - page_background_image: double('background_image', url: 'some_background_url'), - css_property_hash: { page_background_image_repeat: 'some_background_repeat' } - }) - end - - it 'includes the background image as background image style' do - expected_style = 'background: #DFDFDF url(some_background_url) some_background_repeat center top' - expect(helper.render_affiliate_body_style(affiliate)).to eq(expected_style) - end - end - end - describe '#available_templates' do context 'when no templates have been made available' do let(:affiliate) { mock_model(Affiliate, available_templates: []) } diff --git a/spec/models/affiliate_spec.rb b/spec/models/affiliate_spec.rb index d8a16f486f..c515621fcf 100644 --- a/spec/models/affiliate_spec.rb +++ b/spec/models/affiliate_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +# frozen_string_literal: true describe Affiliate do fixtures :users, :affiliates, :site_domains, :features, :youtube_profiles, :memberships, :languages @@ -276,35 +276,6 @@ expect(described_class.find(affiliate.id).css_property_hash[:font_family]).to eq('Verdana, sans-serif') end - it 'should not set header_footer_nested_css fields' do - affiliate.update_attributes!(staged_header_footer_css: '@charset "UTF-8"; @import url("other.css"); h1 { color: blue }', header_footer_css: '') - expect(affiliate.staged_nested_header_footer_css).to be_blank - expect(affiliate.header_footer_css).to be_blank - affiliate.update_attributes!(staged_header_footer_css: '', header_footer_css: '@charset "UTF-8"; @import url("other.css"); live.h1 { color: red }') - expect(affiliate.staged_nested_header_footer_css).to be_blank - expect(affiliate.nested_header_footer_css).to be_blank - end - - it 'should set previous json fields' do - affiliate.previous_header = 'previous header' - affiliate.previous_footer = 'previous footer' - affiliate.save! - expect(described_class.find(affiliate.id).previous_header).to eq('previous header') - expect(described_class.find(affiliate.id).previous_footer).to eq('previous footer') - end - - it 'should set staged and live json fields' do - affiliate.header = 'live header' - affiliate.footer = 'live footer' - affiliate.staged_header = 'staged header' - affiliate.staged_footer = 'staged footer' - affiliate.save! - expect(described_class.find(affiliate.id).header).to eq('live header') - expect(described_class.find(affiliate.id).footer).to eq('live footer') - expect(described_class.find(affiliate.id).staged_header).to eq('staged header') - expect(described_class.find(affiliate.id).staged_footer).to eq('staged footer') - end - it 'should populate search labels for English site' do english_affiliate = described_class.create!(valid_attributes.merge(locale: 'en')) english_affiliate.default_search_label = '' @@ -352,47 +323,6 @@ expect(es_affiliate.rss_govbox_label).to eq('Noticias') end - it 'should remove comments from staged_header and staged_footer fields' do - html_with_comments = <<-HTML -
- - level1 -
- level2 - -
- - level3 -
-
-
- HTML - - html_without_comments = <<-HTML -
- level1 -
- level2 -
- level3 -
-
-
- HTML - affiliate.update_attributes!(staged_header: html_with_comments, staged_footer: html_with_comments) - expect(described_class.find(affiliate.id).staged_header.squish).to eq(html_without_comments.squish) - expect(described_class.find(affiliate.id).staged_footer.squish).to eq(html_without_comments.squish) - end - it 'should squish related sites dropdown label' do affiliate = described_class.create!(valid_create_attributes.merge(locale: 'en', name: 'en-site')) affiliate.related_sites_dropdown_label = ' Search Only' @@ -479,14 +409,6 @@ expect(affiliate.save).to be true end - it 'should not validate staged_header_footer_css for invalid css property value' do - affiliate = described_class.new(valid_create_attributes.merge(staged_header_footer_css: 'h1 { invalid-css-syntax }')) - expect(affiliate.save).to be true - - affiliate = described_class.new(valid_create_attributes.merge(staged_header_footer_css: 'h1 { color: #DDDD }', name: 'anothersite')) - expect(affiliate.save).to be true - end - it 'validates locale is valid' do affiliate = described_class.new(valid_create_attributes.merge(locale: 'invalid_locale')) expect(affiliate.save).to be false @@ -592,115 +514,6 @@ end end - context 'is_validate_staged_header_footer is set to true' do - let(:affiliate) { described_class.create!(display_name: 'test header footer validation', - name: 'testheaderfootervalidation', - uses_managed_header_footer: false, - staged_uses_managed_header_footer: false) } - - before { affiliate.is_validate_staged_header_footer = true } - - it 'should not allow form, script, style or link elements in staged header or staged footer' do - header_error_message = %q(HTML to customize the top of your search results page must not contain form, script, style, link elements) - footer_error_message = %q(HTML to customize the bottom of your search results page must not contain form, script, style, link elements) - - html_with_script = <<-HTML - -

html with script

- HTML - expect(affiliate.update_attributes(staged_header: html_with_script, staged_footer: html_with_script)).to be false - expect(affiliate.errors[:base].join).to match(/#{header_error_message}/) - expect(affiliate.errors[:base].join).to match(/#{footer_error_message}/) - - html_with_style = <<-HTML - -

html with style

- HTML - expect(affiliate.update_attributes(staged_header: html_with_style, staged_footer: html_with_style)).to be false - expect(affiliate.errors[:base].join).to match(/#{header_error_message}/) - expect(affiliate.errors[:base].join).to match(/#{footer_error_message}/) - - html_with_link = <<-HTML - -

html with link

- HTML - expect(affiliate.update_attributes(staged_header: html_with_link, staged_footer: html_with_link)).to be false - expect(affiliate.errors[:base].join).to match(/#{header_error_message}/) - expect(affiliate.errors[:base].join).to match(/#{footer_error_message}/) - - html_with_form = <<-HTML -
-

html with link

- HTML - expect(affiliate.update_attributes(staged_header: html_with_form, staged_footer: html_with_form)).to be false - expect(affiliate.errors[:base].join).to match(/#{header_error_message}/) - expect(affiliate.errors[:base].join).to match(/#{footer_error_message}/) - end - - it 'should not allow onload attribute in staged header or staged footer' do - header_error_message = %q(HTML to customize the top of your search results page must not contain the onload attribute) - footer_error_message = %q(HTML to customize the bottom of your search results page must not contain the onload attribute) - - html_with_onload = <<-HTML -
-

html with onload

- HTML - - expect(affiliate.update_attributes(staged_header: html_with_onload, staged_footer: html_with_onload)).to be false - expect(affiliate.errors[:base].join).to match(/#{header_error_message}/) - expect(affiliate.errors[:base].join).to match(/#{footer_error_message}/) - end - - it 'should not allow malformed HTML in staged header or staged footer' do - header_error_message = 'HTML to customize the top of your search results is invalid' - footer_error_message = 'HTML to customize the bottom of your search results is invalid' - - html_with_body = <<-HTML -

html with script

- HTML - expect(affiliate.update_attributes(staged_header: html_with_body, staged_footer: html_with_body)).to be false - expect(affiliate.errors[:base].join).to include("#{header_error_message}") - expect(affiliate.errors[:base].join).to include("#{footer_error_message}") - - malformed_html_fragments = <<-HTML - -

html with link

- HTML - expect(affiliate.update_attributes(staged_header: malformed_html_fragments, staged_footer: malformed_html_fragments)).to be false - expect(affiliate.errors[:base].join).to include("#{header_error_message}") - expect(affiliate.errors[:base].join).to include("#{footer_error_message}") - end - - it 'should not validate header_footer_css' do - expect(affiliate.update_attributes(header_footer_css: 'h1 { invalid-css-syntax }')).to be true - expect(affiliate.update_attributes(header_footer_css: 'h1 { color: #DDDD }')).to be true - end - - it 'should validate staged_header_footer_css for invalid css property value' do - expect(affiliate.update_attributes(staged_header_footer_css: 'h1 { invalid-css-syntax }')).to be false - expect(affiliate.errors[:base].first).to match(/Invalid CSS/) - - expect(affiliate.update_attributes(staged_header_footer_css: 'h1 { color: #DDDD }')).to be false - expect(affiliate.errors[:base].first).to match(/Colors must have either three or six digits/) - end - end - - context 'is_validate_staged_header_footer is set to false' do - let(:affiliate) { described_class.create!(display_name: 'test header footer validation', - name: 'testheaderfootervalidation', - uses_managed_header_footer: false, - staged_uses_managed_header_footer: false) } - it 'should allow script, style or link elements in staged header or staged footer' do - affiliate.is_validate_staged_header_footer = false - - html_with_script = <<-HTML - -

html with script

- HTML - expect(affiliate.update_attributes(staged_header: html_with_script, staged_footer: html_with_script)).to be true - end - end - it 'allows valid external tracking code' do expect { described_class.create!({ display_name: 'a site', external_tracking_code: '', @@ -726,221 +539,17 @@ end end - describe '#update_attributes_for_staging' do - it 'should set has_staged_content to true and receive update_attributes' do - affiliate = described_class.create!(valid_create_attributes) - attributes = double('attributes') - expect(attributes).to receive(:[]).with(:staged_uses_managed_header_footer).and_return('0') - expect(attributes).to receive(:[]=).with(:has_staged_content, true) - return_value = double('return value') - expect(affiliate).to receive(:update_attributes).with(attributes).and_return(return_value) - expect(affiliate.update_attributes_for_staging(attributes)).to eq(return_value) - end - - context "when attributes contain staged_uses_managed_header_footer='0'" do - it 'should set is_validate_staged_header_footer to true' do - affiliate = described_class.create!(display_name: 'oneserp affiliate', name: 'oneserpaffiliate') - expect(affiliate).to receive(:is_validate_staged_header_footer=).with(true) - affiliate.update_attributes_for_staging(staged_uses_managed_header_footer: '0', - staged_header: 'staged header', - staged_footer: 'staged footer') - end - - it 'should set header_footer_nested_css fields' do - affiliate = described_class.create!(valid_create_attributes) - affiliate.update_attributes!(header_footer_css: '@charset "UTF-8"; @import url("other.css"); h1 { color: blue }') - expect(affiliate.update_attributes_for_staging( - staged_uses_managed_header_footer: '0', - staged_header_footer_css: '@charset "UTF-8"; @import url("other.css"); h1 { color: blue }')).to be true - expect(affiliate.staged_nested_header_footer_css.squish).to match(/^#{Regexp.escape('.header-footer h1{color:blue}')}$/) - end - - it 'should not validated live header_footer_css field' do - affiliate = described_class.create!(valid_create_attributes) - affiliate.update_attributes!(header_footer_css: 'h1 { invalid-css-syntax }') - expect(affiliate.update_attributes_for_staging( - staged_uses_managed_header_footer: '0', - staged_header_footer_css: '@charset "UTF-8"; @import url("other.css"); h1 { color: blue }')).to be true - expect(affiliate.staged_nested_header_footer_css.squish).to match(/^#{Regexp.escape('.header-footer h1{color:blue}')}$/) - end - end - - context "when attributes does not contain staged_uses_managed_header_footer='0'" do - it 'should set is_validate_staged_header_footer to false' do - affiliate = described_class.create!(display_name: 'oneserp affiliate', name: 'oneserpaffiliate') - expect(affiliate).to receive(:is_validate_staged_header_footer=).with(false) - affiliate.update_attributes_for_staging(staged_uses_managed_header_footer: '1') - end - end - end - - describe '#update_attributes_for_live' do - let(:affiliate) { described_class.create!(valid_create_attributes.merge(header: 'old header', footer: 'old footer')) } - - context 'when successfully update_attributes' do - before do - expect(affiliate).to receive(:update_attributes).and_return(true) - end - - it 'should set previous fields' do - expect(affiliate).to receive(:previous_header=).with('old header') - expect(affiliate).to receive(:previous_footer=).with('old footer') - expect(affiliate.update_attributes_for_live(staged_header: 'staged header', staged_footer: 'staged footer')).to be true - end - - it 'should set attributes from staged to live' do - expect(affiliate).to receive(:set_attributes_from_staged_to_live) - expect(affiliate.update_attributes_for_live(staged_header: 'staged header', staged_footer: 'staged footer')).to be true - end - - it 'should set has_staged_content to false' do - expect(affiliate).to receive(:has_staged_content=).with(false) - expect(affiliate.update_attributes_for_live(staged_header: 'staged header', staged_footer: 'staged footer')).to be true - end - - it 'should save!' do - expect(affiliate).to receive(:save!) - expect(affiliate.update_attributes_for_live(staged_header: 'staged header', staged_footer: 'staged footer')).to be true - end - end - - context 'when update_attributes failed' do - before do - expect(affiliate).to receive(:update_attributes).and_return(false) - expect(affiliate).not_to receive(:previous_header=) - expect(affiliate).not_to receive(:previous_footer=) - expect(affiliate).not_to receive(:save!) - end - - specify { expect(affiliate.update_attributes_for_live(staged_header: 'staged header', staged_footer: 'staged footer')).to be false } - end - - context "when attributes contain staged_uses_managed_header_footer='0'" do - it 'should set is_validate_staged_header_footer to true' do - expect(affiliate).to receive(:is_validate_staged_header_footer=).with(true) - affiliate.update_attributes_for_live(staged_uses_managed_header_footer: '0', - staged_header: 'staged header', - staged_footer: 'staged footer') - end - - it 'should set header_footer_nested_css fields' do - affiliate = described_class.create!(valid_create_attributes) - expect(affiliate.update_attributes_for_live( - staged_uses_managed_header_footer: '0', - staged_header_footer_css: '@charset "UTF-8"; @import url("other.css"); h1 { color: blue }')).to be true - expect(affiliate.staged_nested_header_footer_css.squish).to match(/^#{Regexp.escape('.header-footer h1{color:blue}')}$/) - expect(affiliate.nested_header_footer_css.squish).to match(/^#{Regexp.escape('.header-footer h1{color:blue}')}$/) - end - - it 'should not validated live header_footer_css field' do - affiliate = described_class.create!(valid_create_attributes) - affiliate.update_attributes!(header_footer_css: 'h1 { invalid-css-syntax }') - expect(affiliate.update_attributes_for_live( - staged_uses_managed_header_footer: '0', - staged_header_footer_css: '@charset "UTF-8"; @import url("other.css"); h1 { color: blue }')).to be true - expect(affiliate.staged_nested_header_footer_css.squish).to match(/^#{Regexp.escape('.header-footer h1{color:blue}')}$/) - expect(affiliate.nested_header_footer_css.squish).to match(/^#{Regexp.escape('.header-footer h1{color:blue}')}$/) - end - end - - context "when attributes does not contain staged_uses_managed_header_footer='0'" do - it 'should set is_validate_staged_header_footer to false' do - expect(affiliate).to receive(:is_validate_staged_header_footer=).with(false) - affiliate.update_attributes_for_live(staged_uses_managed_header_footer: '1') - end - end - end - - describe '#set_attributes_from_staged_to_live' do - let(:affiliate) { described_class.create!(valid_create_attributes) } - - it 'should set live fields with values from staged fields' do - Affiliate::ATTRIBUTES_WITH_STAGED_AND_LIVE.each do |attribute| - staged_value = double("staged_value for #{attribute}") - expect(affiliate).to receive("staged_#{attribute}".to_sym).and_return(staged_value) - expect(affiliate).to receive("#{attribute}=".to_sym).with(staged_value) - end - affiliate.set_attributes_from_staged_to_live - end - end - - describe '#set_attributes_from_live_to_staged' do - let(:affiliate) { described_class.create!(valid_create_attributes) } - - it 'should set staged fields with values from live fields' do - Affiliate::ATTRIBUTES_WITH_STAGED_AND_LIVE.each do |attribute| - live_value = double("live_value for #{attribute}") - expect(affiliate).to receive("#{attribute}".to_sym).and_return(live_value) - expect(affiliate).to receive("staged_#{attribute}=".to_sym).with(live_value) - end - affiliate.set_attributes_from_live_to_staged - end - end - describe '.human_attribute_name' do specify { expect(described_class.human_attribute_name('display_name')).to eq('Display name') } specify { expect(described_class.human_attribute_name('name')).to eq('Site Handle (visible to searchers in the URL)') } end - describe '#push_staged_changes' do - it 'should set attributes from staged to live fields, set has_staged_content to false and save!' do - affiliate = described_class.create!(valid_create_attributes) - expect(affiliate).to receive(:set_attributes_from_staged_to_live) - expect(affiliate).to receive(:has_staged_content=).with(false) - expect(affiliate).to receive(:save!) - affiliate.push_staged_changes - end - end - - describe '#cancel_staged_changes' do - it 'should set attributes from live to staged fields, set has_staged_content to false and save!' do - affiliate = described_class.create!(valid_create_attributes) - expect(affiliate).to receive(:set_attributes_from_live_to_staged) - expect(affiliate).to receive(:has_staged_content=).with(false) - expect(affiliate).to receive(:save!) - affiliate.cancel_staged_changes - end - - it 'should copy header_footer_css' do - affiliate = described_class.create!(valid_create_attributes) - affiliate.update_attributes!(header_footer_css: 'h1 { invalid-css-syntax }', - nested_header_footer_css: '.header_footer h1 { invalid-css-syntax }') - described_class.find(affiliate.id).cancel_staged_changes - - aff_after_cancel = described_class.find(affiliate.id) - expect(aff_after_cancel.staged_header_footer_css).to eq('h1 { invalid-css-syntax }') - expect(aff_after_cancel.staged_nested_header_footer_css).to eq('.header_footer h1 { invalid-css-syntax }') - end - end - describe '#ordered' do it "should include a scope called 'ordered'" do expect(described_class.ordered).not_to be_nil end end - describe '#sync_staged_attributes' do - context 'when the affiliate has staged content' do - let(:affiliate) { affiliates(:basic_affiliate) } - before do - expect(affiliate).to receive(:has_staged_content?).and_return(false) - expect(affiliate).to receive(:cancel_staged_changes).and_return(true) - end - - specify { expect(affiliate.sync_staged_attributes).to be true } - end - - context 'when the affiliate does not have staged content' do - let(:affiliate) { affiliates(:basic_affiliate) } - before do - expect(affiliate).to receive(:has_staged_content?).and_return(true) - expect(affiliate).not_to receive(:cancel_staged_changes) - end - - specify { expect(affiliate.sync_staged_attributes).to be_nil } - end - end - describe '#has_multiple_domains?' do let(:affiliate) { described_class.create!(valid_create_attributes) } @@ -1192,34 +801,6 @@ end end - describe '#sanitized_header' do - it 'should remove all banned HTML elements' do - tainted_header = <<-HTML - - - -

header

- HTML - - affiliate = described_class.create!(valid_attributes.merge(header: tainted_header)) - expect(affiliate.sanitized_header.strip).to eq(%q(

header

)) - end - end - - describe '#sanitized_footer' do - it 'should remove all banned HTML elements' do - tainted_footer = <<-HTML - - - -

footer

- HTML - - affiliate = described_class.create!(valid_attributes.merge(footer: tainted_footer)) - expect(affiliate.sanitized_footer.strip).to eq(%q(

footer

)) - end - end - describe '#unused_features' do before do @affiliate = affiliates(:power_affiliate) @@ -1267,7 +848,7 @@ describe '#mobile_logo_url' do it 'returns mobile logo url' do - mobile_logo_url = 'http://link.to/mobile_logo.png'.freeze + mobile_logo_url = 'http://link.to/mobile_logo.png' mobile_logo = double('mobile logo') affiliate = affiliates(:power_affiliate) expect(affiliate).to receive(:mobile_logo_file_name).and_return('mobile_logo.png') @@ -1280,7 +861,7 @@ describe '#header_image_url' do it 'returns header image url' do - header_image_url = 'http://link.to/header_image.png'.freeze + header_image_url = 'http://link.to/header_image.png' header_image = double('header image') affiliate = affiliates(:power_affiliate) expect(affiliate).to receive(:header_image_file_name).and_return('header_image.png')