From 82cb8d4c5215d09fc64fbde6df53f33e461d9ee1 Mon Sep 17 00:00:00 2001 From: iagirre Date: Wed, 24 Jan 2018 16:23:12 +0100 Subject: [PATCH] Changes suggested in PR: * Delete all things related to banner images and styles (in code) * Add a new test to check that the banner is showing correctly * Update the specs accordingly to match the changes Update dev_seed to set a random background_color and a font_color for banners (and remove everything about image and style) Add a rake task to migrate the banner style to backgroun_color and font_color (so that the banners have the same colors than before) --- app/assets/javascripts/banners.js.coffee | 12 +---- app/controllers/admin/banners_controller.rb | 4 +- app/views/admin/banners/_form.html.erb | 12 ++--- app/views/admin/banners/index.html.erb | 12 ++--- app/views/shared/_banner.html.erb | 12 ++--- lib/tasks/banners.rake | 20 ++++++++ spec/factories.rb | 4 +- spec/features/admin/banners_spec.rb | 57 +++++++++++++-------- 8 files changed, 75 insertions(+), 58 deletions(-) create mode 100644 lib/tasks/banners.rake diff --git a/app/assets/javascripts/banners.js.coffee b/app/assets/javascripts/banners.js.coffee index e7748c148..d38587083 100644 --- a/app/assets/javascripts/banners.js.coffee +++ b/app/assets/javascripts/banners.js.coffee @@ -24,21 +24,13 @@ App.Banners = change: -> App.Banners.update_banner("#js-banner-description", $(this).val()) - $("#banner_style").on - change: -> - App.Banners.update_style("#js-banner-style", $(this).val()) - - $("#banner_image").on - change: -> - App.Banners.update_style("#js-banner-image", $(this).val()) - $("#banner_background_color_picker").on change: -> - App.Banners.update_background_color("#js-banner-style", "#banner_background_color", $(this).val()); + App.Banners.update_background_color("#js-banner-background", "#banner_background_color", $(this).val()); $("#banner_background_color").on change: -> - App.Banners.update_background_color("#js-banner-style", "#banner_background_color_picker", $(this).val()); + App.Banners.update_background_color("#js-banner-background", "#banner_background_color_picker", $(this).val()); $("#banner_font_color_picker").on change: -> diff --git a/app/controllers/admin/banners_controller.rb b/app/controllers/admin/banners_controller.rb index 802110063..25038b80f 100644 --- a/app/controllers/admin/banners_controller.rb +++ b/app/controllers/admin/banners_controller.rb @@ -2,8 +2,6 @@ class Admin::BannersController < Admin::BaseController has_filters %w{all with_active with_inactive}, only: :index - before_action :banner_styles, only: [:edit, :new, :create, :update] - before_action :banner_imgs, only: [:edit, :new, :create, :update] before_action :banner_sections, only: [:edit, :new, :create, :update] respond_to :html, :js @@ -39,7 +37,7 @@ class Admin::BannersController < Admin::BaseController private def banner_params - attributes = [:title, :description, :target_url, :style, :image, + attributes = [:title, :description, :target_url, :post_started_at, :post_ended_at, :background_color, :font_color, web_section_ids: []] diff --git a/app/views/admin/banners/_form.html.erb b/app/views/admin/banners/_form.html.erb index dc0fb0634..d9ab0e609 100644 --- a/app/views/admin/banners/_form.html.erb +++ b/app/views/admin/banners/_form.html.erb @@ -77,12 +77,10 @@ <%= f.submit(class: "button expanded", value: t("admin.banners.edit.form.submit_button")) %> -