BIN
app/assets/images/banners/banner1.png
Normal file
BIN
app/assets/images/banners/banner1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
BIN
app/assets/images/banners/banner2.png
Normal file
BIN
app/assets/images/banners/banner2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
BIN
app/assets/images/banners/banner3.png
Normal file
BIN
app/assets/images/banners/banner3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
@@ -23,6 +23,8 @@ App.AdvancedSearch =
|
|||||||
$('.js-calendar').datepicker
|
$('.js-calendar').datepicker
|
||||||
regional: locale
|
regional: locale
|
||||||
maxDate: "+0d"
|
maxDate: "+0d"
|
||||||
|
$('.js-calendar-full').datepicker
|
||||||
|
regional: locale
|
||||||
|
|
||||||
initialize: ->
|
initialize: ->
|
||||||
App.AdvancedSearch.init_calendar()
|
App.AdvancedSearch.init_calendar()
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
//= require tracks
|
//= require tracks
|
||||||
//= require valuation_spending_proposal_form
|
//= require valuation_spending_proposal_form
|
||||||
//= require embed_video
|
//= require embed_video
|
||||||
|
//= require banners
|
||||||
|
|
||||||
var initialize_modules = function() {
|
var initialize_modules = function() {
|
||||||
App.Comments.initialize();
|
App.Comments.initialize();
|
||||||
@@ -63,6 +64,7 @@ var initialize_modules = function() {
|
|||||||
App.Tracks.initialize();
|
App.Tracks.initialize();
|
||||||
App.ValuationSpendingProposalForm.initialize();
|
App.ValuationSpendingProposalForm.initialize();
|
||||||
App.EmbedVideo.initialize();
|
App.EmbedVideo.initialize();
|
||||||
|
App.Banners.initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|||||||
25
app/assets/javascripts/banners.js.coffee
Normal file
25
app/assets/javascripts/banners.js.coffee
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
App.Banners =
|
||||||
|
|
||||||
|
update_banner: (selector, text) ->
|
||||||
|
$(selector).html(text)
|
||||||
|
|
||||||
|
update_style: (selector, style) ->
|
||||||
|
$(selector).removeClass($(selector).attr("class"), true)
|
||||||
|
.addClass(style, true)
|
||||||
|
|
||||||
|
initialize: ->
|
||||||
|
$('[data-js-banner-title]').on
|
||||||
|
change: ->
|
||||||
|
App.Banners.update_banner("#js-banner-title", $(this).val())
|
||||||
|
|
||||||
|
$('[data-js-banner-description]').on
|
||||||
|
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())
|
||||||
@@ -145,6 +145,7 @@ body.admin {
|
|||||||
|
|
||||||
li a:not(.button) {
|
li a:not(.button) {
|
||||||
color: rgba(255,255,255,0.3);
|
color: rgba(255,255,255,0.3);
|
||||||
|
display: block;
|
||||||
line-height: rem-calc(48);
|
line-height: rem-calc(48);
|
||||||
padding-left: rem-calc(12);
|
padding-left: rem-calc(12);
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
border-right: 1px solid $dark;
|
border-right: 1px solid $dark;
|
||||||
|
|
||||||
tr th {
|
tr th {
|
||||||
color: white;
|
color: $dark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
// 15. Comments
|
// 15. Comments
|
||||||
// 16. Flags
|
// 16. Flags
|
||||||
// 17. Activity
|
// 17. Activity
|
||||||
|
// 18. Banners
|
||||||
//
|
//
|
||||||
|
|
||||||
// 01. Global styles
|
// 01. Global styles
|
||||||
@@ -1686,3 +1687,69 @@ table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 18. Banners
|
||||||
|
// -----------
|
||||||
|
|
||||||
|
.banner-style-one {
|
||||||
|
background-color: $brand;
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner-style-two {
|
||||||
|
background-color: $budget;
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner-style-three {
|
||||||
|
background-color: #33DADF;
|
||||||
|
}
|
||||||
|
|
||||||
|
@include breakpoint(large) {
|
||||||
|
|
||||||
|
.banner-img-one {
|
||||||
|
background-image: image-url('banners/banner1.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner-img-two {
|
||||||
|
background-image: image-url('banners/banner2.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner-img-three {
|
||||||
|
background-image: image-url('banners/banner3.png');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner-img-one, .banner-img-two, .banner-img-three {
|
||||||
|
background-position: bottom right;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner-style-one, .banner-style-two, .banner-style-three {
|
||||||
|
margin: 0;
|
||||||
|
margin-bottom: $line-height;
|
||||||
|
|
||||||
|
h2, h3, a {
|
||||||
|
color: #eaeaf2;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
padding: $line-height/2;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
padding: $line-height/2;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover h2, a:hover h3 {
|
||||||
|
color: #eaeaf2 !important;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@include breakpoint(large) {
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
@mixin logo {
|
@mixin logo {
|
||||||
color: white;
|
color: white;
|
||||||
|
display: inline-block;
|
||||||
font-family: 'Lato' !important;
|
font-family: 'Lato' !important;
|
||||||
font-size: rem-calc(24);
|
font-size: rem-calc(24);
|
||||||
font-weight: lighter;
|
font-weight: lighter;
|
||||||
|
|||||||
56
app/controllers/admin/banners_controller.rb
Normal file
56
app/controllers/admin/banners_controller.rb
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
class Admin::BannersController < Admin::BaseController
|
||||||
|
|
||||||
|
has_filters %w{all with_active with_inactive}, only: :index
|
||||||
|
|
||||||
|
before_action :find_banner, only: [:edit, :update, :destroy]
|
||||||
|
before_action :banner_styles, only: [:edit, :new, :create, :update]
|
||||||
|
before_action :banner_imgs, only: [:edit, :new, :create, :update]
|
||||||
|
|
||||||
|
respond_to :html, :js
|
||||||
|
|
||||||
|
load_and_authorize_resource
|
||||||
|
|
||||||
|
def index
|
||||||
|
@banners = Banner.send(@current_filter).page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@banner = Banner.new(banner_params)
|
||||||
|
if @banner.save
|
||||||
|
redirect_to admin_banners_path
|
||||||
|
else
|
||||||
|
render :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@banner.assign_attributes(banner_params)
|
||||||
|
if @banner.update(banner_params)
|
||||||
|
redirect_to admin_banners_path
|
||||||
|
else
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@banner.destroy
|
||||||
|
redirect_to admin_banners_path
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def banner_params
|
||||||
|
params.require(:banner).permit(:title, :description, :target_url, :style, :image, :post_started_at, :post_ended_at)
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_banner
|
||||||
|
@banner = Banner.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def banner_styles
|
||||||
|
@banner_styles = Setting.all.banner_style.map { |banner_style| [banner_style.value, banner_style.key.split('.')[1]] }
|
||||||
|
end
|
||||||
|
|
||||||
|
def banner_imgs
|
||||||
|
@banner_imgs = Setting.all.banner_img.map { |banner_img| [banner_img.value, banner_img.key.split('.')[1]] }
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
class Admin::SettingsController < Admin::BaseController
|
class Admin::SettingsController < Admin::BaseController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
all_settings = (Setting.all).group_by { |s| s.feature_flag? }
|
all_settings = (Setting.all).group_by { |s| s.type }
|
||||||
@settings = all_settings[false]
|
@settings = all_settings['common']
|
||||||
@feature_flags = all_settings[true]
|
@feature_flags = all_settings['feature']
|
||||||
|
@banner_styles = all_settings['banner-style']
|
||||||
|
@banner_imgs = all_settings['banner-img']
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ module CommentableActions
|
|||||||
index_customization if index_customization.present?
|
index_customization if index_customization.present?
|
||||||
|
|
||||||
@tag_cloud = tag_cloud
|
@tag_cloud = tag_cloud
|
||||||
|
@banners = Banner.with_active
|
||||||
|
|
||||||
set_resource_votes(@resources)
|
set_resource_votes(@resources)
|
||||||
set_resources_instance
|
set_resources_instance
|
||||||
end
|
end
|
||||||
|
|||||||
5
app/helpers/banners_helper.rb
Normal file
5
app/helpers/banners_helper.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module BannersHelper
|
||||||
|
def has_banners
|
||||||
|
@banners.count > 0
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -42,6 +42,7 @@ module Abilities
|
|||||||
can :manage, Annotation
|
can :manage, Annotation
|
||||||
|
|
||||||
can [:read, :update, :destroy, :summary], SpendingProposal
|
can [:read, :update, :destroy, :summary], SpendingProposal
|
||||||
|
can [:search, :edit, :update, :create, :index, :destroy], Banner
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
20
app/models/banner.rb
Normal file
20
app/models/banner.rb
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
class Banner < ActiveRecord::Base
|
||||||
|
|
||||||
|
acts_as_paranoid column: :hidden_at
|
||||||
|
include ActsAsParanoidAliases
|
||||||
|
|
||||||
|
validates :title, presence: true,
|
||||||
|
length: { minimum: 2 }
|
||||||
|
validates :description, presence: true
|
||||||
|
validates :target_url, presence: true
|
||||||
|
validates :style, presence: true
|
||||||
|
validates :image, presence: true
|
||||||
|
validates :post_started_at, presence: true
|
||||||
|
validates :post_ended_at, presence: true
|
||||||
|
|
||||||
|
scope :with_active, -> {where("post_started_at <= ?", Time.now).
|
||||||
|
where("post_ended_at >= ?", Time.now) }
|
||||||
|
|
||||||
|
scope :with_inactive,-> {where("post_started_at > ? or post_ended_at < ?", Time.now, Time.now) }
|
||||||
|
|
||||||
|
end
|
||||||
@@ -2,6 +2,20 @@ class Setting < ActiveRecord::Base
|
|||||||
validates :key, presence: true, uniqueness: true
|
validates :key, presence: true, uniqueness: true
|
||||||
|
|
||||||
default_scope { order(id: :asc) }
|
default_scope { order(id: :asc) }
|
||||||
|
scope :banner_style, -> { where("key ilike ?", "banner-style.%")}
|
||||||
|
scope :banner_img, -> { where("key ilike ?", "banner-img.%")}
|
||||||
|
|
||||||
|
def type
|
||||||
|
if feature_flag?
|
||||||
|
'feature'
|
||||||
|
elsif banner_style?
|
||||||
|
'banner-style'
|
||||||
|
elsif banner_img?
|
||||||
|
'banner-img'
|
||||||
|
else
|
||||||
|
'common'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def feature_flag?
|
def feature_flag?
|
||||||
key.start_with?('feature.')
|
key.start_with?('feature.')
|
||||||
@@ -11,6 +25,14 @@ class Setting < ActiveRecord::Base
|
|||||||
feature_flag? && value.present?
|
feature_flag? && value.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def banner_style?
|
||||||
|
key.start_with?('banner-style.')
|
||||||
|
end
|
||||||
|
|
||||||
|
def banner_img?
|
||||||
|
key.start_with?('banner-img.')
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def [](key)
|
def [](key)
|
||||||
where(key: key).pluck(:value).first.presence
|
where(key: key).pluck(:value).first.presence
|
||||||
|
|||||||
@@ -43,6 +43,13 @@
|
|||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<li <%= "class=active" if controller_name == "banners" %>>
|
||||||
|
<%= link_to admin_banners_path do %>
|
||||||
|
<span class="icon-eye"></span>
|
||||||
|
<%= t("admin.menu.banner") %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li <%= "class=active" if controller_name == "users" %>>
|
<li <%= "class=active" if controller_name == "users" %>>
|
||||||
<%= link_to admin_users_path do %>
|
<%= link_to admin_users_path do %>
|
||||||
<span class="icon-eye"></span>
|
<span class="icon-eye"></span>
|
||||||
|
|||||||
15
app/views/admin/banners/_errors.html.erb
Normal file
15
app/views/admin/banners/_errors.html.erb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
<% if @banner.errors.any? %>
|
||||||
|
|
||||||
|
<div id="error_explanation" data-alert class="callout alert" data-closable>
|
||||||
|
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<strong>
|
||||||
|
<%= @banner.errors.count %>
|
||||||
|
<%= t("admin.banners.errors.form.error", count: @banner.errors.count) %>
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
69
app/views/admin/banners/_form.html.erb
Normal file
69
app/views/admin/banners/_form.html.erb
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<%= form_for [:admin, @banner] do |f| %>
|
||||||
|
|
||||||
|
<%= render 'errors' %>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-3 column">
|
||||||
|
<%= f.label :style, t("admin.banners.banner.style") %>
|
||||||
|
<%= f.select :style, options_for_select(@banner_styles, @banner.style),:include_blank => '-',
|
||||||
|
label: false,placeholder: t("admin.banners.banner.style") %>
|
||||||
|
</div>
|
||||||
|
<div class="small-3 column">
|
||||||
|
<%= f.label :image, t("admin.banners.banner.image") %>
|
||||||
|
<%= f.select :image, options_for_select(@banner_imgs, @banner.image),:include_blank => '-',
|
||||||
|
label: false, placeholder: t("admin.banners.banner.image") %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= f.label :title, t("admin.banners.banner.title") %>
|
||||||
|
<%= f.text_field :title, placeholder: t("admin.banners.banner.title"), label: false,
|
||||||
|
data: {js_banner_title: "js_banner_title"} %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= f.label :description, t("admin.banners.banner.description") %>
|
||||||
|
<%= f.text_field :description,
|
||||||
|
label: false,
|
||||||
|
data: {js_banner_description: "js_banner_description"},
|
||||||
|
placeholder: t("admin.banners.banner.description") %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= f.label :target_url, t("admin.banners.banner.target_url") %>
|
||||||
|
<%= f.text_field :target_url,
|
||||||
|
label: false,
|
||||||
|
placeholder: t("admin.banners.banner.target_url") %>
|
||||||
|
</div>
|
||||||
|
<% date_started_at = @banner.post_started_at.present? ? I18n.localize(@banner.post_started_at) : "" %>
|
||||||
|
<div class="small-3 column">
|
||||||
|
<%= f.label :post_started_at, t("admin.banners.banner.post_started_at") %>
|
||||||
|
<%= f.text_field :post_started_at,
|
||||||
|
label: false,
|
||||||
|
placeholder: t("admin.banners.banner.post_started_at"),
|
||||||
|
value: date_started_at,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "post_started_at" %>
|
||||||
|
</div>
|
||||||
|
<% date_ended_at = @banner.post_ended_at.present? ? I18n.localize(@banner.post_ended_at) : ""%>
|
||||||
|
<div class="small-3 column">
|
||||||
|
<%= f.label :post_ended_at, t("admin.banners.banner.post_ended_at") %>
|
||||||
|
<%= f.text_field :post_ended_at,
|
||||||
|
label: false,
|
||||||
|
placeholder: t("admin.banners.banner.post_ended_at"),
|
||||||
|
value: date_ended_at,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "post_ended_at" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="actions small-12 column">
|
||||||
|
<%= f.submit(class: "button", value: t("admin.banners.edit.form.submit_button")) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="js-banner-style" class="<%= @banner.style %>">
|
||||||
|
<div id="js-banner-image" class="<%= @banner.image %>">
|
||||||
|
<%= link_to @banner.target_url do %>
|
||||||
|
<h2 id="js-banner-title"><%= @banner.title %></h2>
|
||||||
|
<h3 id="js-banner-description"><%= @banner.description %></h3>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
13
app/views/admin/banners/edit.html.erb
Normal file
13
app/views/admin/banners/edit.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="banner-edit row">
|
||||||
|
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= link_to admin_banners_path, class: "back" do %>
|
||||||
|
<span class="icon-angle-left"></span>
|
||||||
|
<%= t("admin.banners.edit.back") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<h1><%= t("admin.banners.edit.editing") %></h1>
|
||||||
|
|
||||||
|
<%= render "form" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
45
app/views/admin/banners/index.html.erb
Normal file
45
app/views/admin/banners/index.html.erb
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<%= link_to t("admin.banners.index.create"),
|
||||||
|
new_admin_banner_path, class: "button large success float-right" %>
|
||||||
|
|
||||||
|
<h2 class="inline-block"><%= t("admin.banners.index.title") %></h2>
|
||||||
|
|
||||||
|
<%= render 'shared/filter_subnav', i18n_namespace: "admin.banners.index" %>
|
||||||
|
|
||||||
|
<h3><%= page_entries_info @banners %></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<% @banners.each do |banner| %>
|
||||||
|
<tr id="<%= dom_id(banner) %>">
|
||||||
|
<td class="small-12 medium-9">
|
||||||
|
<div class="<%= banner.style %>">
|
||||||
|
<div class="<%= banner.image %>">
|
||||||
|
<%= link_to banner.target_url do %>
|
||||||
|
<h2><%= banner.title %></h2>
|
||||||
|
<h3><%= banner.description %></h3>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= t("admin.banners.banner.post_started_at")%> <strong><%= banner.post_started_at %></strong>
|
||||||
|
|
|
||||||
|
<%= t("admin.banners.banner.post_ended_at")%> <strong><%= banner.post_ended_at%></strong>
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<%= link_to edit_admin_banner_path(banner),
|
||||||
|
class: 'edit-banner button' do %>
|
||||||
|
<span class="icon-edit"></span>
|
||||||
|
<%= t("admin.banners.index.edit") %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= link_to admin_banner_path(banner), method: :delete,
|
||||||
|
class: 'delete' do %>
|
||||||
|
<span class="icon-delete"></span>
|
||||||
|
<%= t("admin.banners.index.delete") %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= paginate @banners %>
|
||||||
13
app/views/admin/banners/new.html.erb
Normal file
13
app/views/admin/banners/new.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="banner-new row">
|
||||||
|
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= link_to admin_banners_path, class: "back" do %>
|
||||||
|
<span class="icon-angle-left"></span>
|
||||||
|
<%= t("admin.banners.new.back") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<h1><%= t("admin.banners.new.creating") %></h1>
|
||||||
|
|
||||||
|
<%= render "form" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -32,3 +32,37 @@
|
|||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<% if @banner_styles.present? %>
|
||||||
|
<h2><%= t("admin.settings.index.banners") %></h2>
|
||||||
|
|
||||||
|
<ul class="admin-list">
|
||||||
|
<% @banner_styles.each do |setting| %>
|
||||||
|
<li>
|
||||||
|
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||||
|
|
||||||
|
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||||
|
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||||
|
<%= f.submit(t('admin.settings.index.update_setting'), class: "button small success") %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if @banner_imgs.present?%>
|
||||||
|
<h2><%= t("admin.settings.index.banner_imgs") %></h2>
|
||||||
|
|
||||||
|
<ul class="admin-list">
|
||||||
|
<% @banner_imgs.each do |setting| %>
|
||||||
|
<li>
|
||||||
|
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||||
|
|
||||||
|
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||||
|
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||||
|
<%= f.submit(t('admin.settings.index.update_setting'), class: "button small success") %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% if has_banners %>
|
||||||
|
<%= render "shared/banner" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% unless @tag_filter || @search_terms || !has_featured? %>
|
<% unless @tag_filter || @search_terms || !has_featured? %>
|
||||||
<%= render "featured_debates" %>
|
<%= render "featured_debates" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% if has_banners %>
|
||||||
|
<%= render "shared/banner" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if @featured_proposals.present? %>
|
<% if @featured_proposals.present? %>
|
||||||
<div id="featured-proposals" class="row featured-proposals">
|
<div id="featured-proposals" class="row featured-proposals">
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
|
|||||||
9
app/views/shared/_banner.html.erb
Normal file
9
app/views/shared/_banner.html.erb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<% banner = @banners.sample%>
|
||||||
|
<div class="<%= banner.style %>">
|
||||||
|
<div class="<%= banner.image %>">
|
||||||
|
<%= link_to banner.target_url do %>
|
||||||
|
<h2><%=banner.title%></h2>
|
||||||
|
<h3><%=banner.description%></h3>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -107,6 +107,7 @@ ignore_unused:
|
|||||||
- 'unauthorized.*'
|
- 'unauthorized.*'
|
||||||
- 'admin.officials.level_*'
|
- 'admin.officials.level_*'
|
||||||
- 'admin.comments.index.filter*'
|
- 'admin.comments.index.filter*'
|
||||||
|
- 'admin.banners.index.filters.*'
|
||||||
- 'admin.debates.index.filter*'
|
- 'admin.debates.index.filter*'
|
||||||
- 'admin.proposals.index.filter*'
|
- 'admin.proposals.index.filter*'
|
||||||
- 'admin.spending_proposals.index.filter*'
|
- 'admin.spending_proposals.index.filter*'
|
||||||
|
|||||||
@@ -9,6 +9,39 @@ en:
|
|||||||
restore: Restore
|
restore: Restore
|
||||||
mark_featured: Featured
|
mark_featured: Featured
|
||||||
unmark_featured: Unmark featured
|
unmark_featured: Unmark featured
|
||||||
|
banners:
|
||||||
|
index:
|
||||||
|
title: Banners
|
||||||
|
create: Create banner
|
||||||
|
edit: Edit banner
|
||||||
|
delete: Delete banner
|
||||||
|
filters:
|
||||||
|
all: All
|
||||||
|
with_active: Active
|
||||||
|
with_inactive: Inactive
|
||||||
|
banner:
|
||||||
|
title: Title
|
||||||
|
description: Description
|
||||||
|
target_url: Link
|
||||||
|
style: Style
|
||||||
|
image: Image
|
||||||
|
post_started_at: Post started at
|
||||||
|
post_ended_at: Post ended at
|
||||||
|
edit:
|
||||||
|
back: Back
|
||||||
|
editing: Edit banner
|
||||||
|
form:
|
||||||
|
submit_button: Save changes
|
||||||
|
errors:
|
||||||
|
form:
|
||||||
|
errors:
|
||||||
|
form:
|
||||||
|
error:
|
||||||
|
one: "prevented this banner from being saved"
|
||||||
|
other: 'prevented this banner from being saved'
|
||||||
|
new:
|
||||||
|
back: Back
|
||||||
|
creating: Create banner
|
||||||
activity:
|
activity:
|
||||||
show:
|
show:
|
||||||
action: Action
|
action: Action
|
||||||
@@ -59,6 +92,7 @@ en:
|
|||||||
user_not_found: User not found
|
user_not_found: User not found
|
||||||
menu:
|
menu:
|
||||||
activity: Moderator activity
|
activity: Moderator activity
|
||||||
|
banner: Manage banners
|
||||||
debate_topics: Debate topics
|
debate_topics: Debate topics
|
||||||
hidden_comments: Hidden comments
|
hidden_comments: Hidden comments
|
||||||
hidden_debates: Hidden debates
|
hidden_debates: Hidden debates
|
||||||
@@ -155,6 +189,8 @@ en:
|
|||||||
flash:
|
flash:
|
||||||
updated: Value updated
|
updated: Value updated
|
||||||
index:
|
index:
|
||||||
|
banners: Estilos de banners
|
||||||
|
banner_imgs: Imágenes para los banners
|
||||||
title: Configuration settings
|
title: Configuration settings
|
||||||
update_setting: Update
|
update_setting: Update
|
||||||
feature_flags: Features
|
feature_flags: Features
|
||||||
|
|||||||
@@ -9,6 +9,37 @@ es:
|
|||||||
restore: Volver a mostrar
|
restore: Volver a mostrar
|
||||||
mark_featured: Destacar
|
mark_featured: Destacar
|
||||||
unmark_featured: Quitar destacado
|
unmark_featured: Quitar destacado
|
||||||
|
banners:
|
||||||
|
index:
|
||||||
|
title: Anuncios
|
||||||
|
create: Crear un banner
|
||||||
|
edit: Editar banner
|
||||||
|
delete: Eliminar banner
|
||||||
|
filters:
|
||||||
|
all: Todos
|
||||||
|
with_active: Activos
|
||||||
|
with_inactive: Inactivos
|
||||||
|
banner:
|
||||||
|
title: Título
|
||||||
|
description: Descripción
|
||||||
|
target_url: Enlace
|
||||||
|
style: Estilo
|
||||||
|
image: Imagen
|
||||||
|
post_started_at: Inicio de publicación
|
||||||
|
post_ended_at: Fin de publicación
|
||||||
|
edit:
|
||||||
|
back: Volver
|
||||||
|
editing: Editar el banner
|
||||||
|
form:
|
||||||
|
submit_button: Guardar Cambios
|
||||||
|
errors:
|
||||||
|
form:
|
||||||
|
error:
|
||||||
|
one: "error impidió guardar el banner"
|
||||||
|
other: "errores impidieron guardar el banner."
|
||||||
|
new:
|
||||||
|
back: Volver
|
||||||
|
creating: Crear banner
|
||||||
activity:
|
activity:
|
||||||
show:
|
show:
|
||||||
action: Acción
|
action: Acción
|
||||||
@@ -59,6 +90,7 @@ es:
|
|||||||
user_not_found: Usuario no encontrado
|
user_not_found: Usuario no encontrado
|
||||||
menu:
|
menu:
|
||||||
activity: Actividad de moderadores
|
activity: Actividad de moderadores
|
||||||
|
banner: Gestionar banners
|
||||||
debate_topics: Temas de debate
|
debate_topics: Temas de debate
|
||||||
hidden_comments: Comentarios ocultos
|
hidden_comments: Comentarios ocultos
|
||||||
hidden_debates: Debates ocultos
|
hidden_debates: Debates ocultos
|
||||||
@@ -155,6 +187,8 @@ es:
|
|||||||
flash:
|
flash:
|
||||||
updated: Valor actualizado
|
updated: Valor actualizado
|
||||||
index:
|
index:
|
||||||
|
banners: Banner style
|
||||||
|
banner_imgs: Banner images
|
||||||
title: Configuración global
|
title: Configuración global
|
||||||
update_setting: Actualizar
|
update_setting: Actualizar
|
||||||
feature_flags: Funcionalidades
|
feature_flags: Funcionalidades
|
||||||
|
|||||||
@@ -143,6 +143,10 @@ Rails.application.routes.draw do
|
|||||||
get :summary, on: :collection
|
get :summary, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do
|
||||||
|
collection { get :search}
|
||||||
|
end
|
||||||
|
|
||||||
resources :comments, only: :index do
|
resources :comments, only: :index do
|
||||||
member do
|
member do
|
||||||
put :restore
|
put :restore
|
||||||
|
|||||||
@@ -318,3 +318,21 @@ puts "Confirming hiding in debates, comments & proposals"
|
|||||||
Comment.only_hidden.flagged.reorder("RANDOM()").limit(10).each(&:confirm_hide)
|
Comment.only_hidden.flagged.reorder("RANDOM()").limit(10).each(&:confirm_hide)
|
||||||
Debate.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
|
Debate.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
|
||||||
Proposal.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
|
Proposal.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
|
||||||
|
|
||||||
|
puts "Creating banners"
|
||||||
|
|
||||||
|
Proposal.last(3).each do |proposal|
|
||||||
|
title = Faker::Lorem.sentence(word_count = 3)
|
||||||
|
description = Faker::Lorem.sentence(word_count = 12)
|
||||||
|
banner = Banner.create!(title: title,
|
||||||
|
description: description,
|
||||||
|
style: ["banner-style banner-style-one", "banner-style banner-style-two",
|
||||||
|
"banner-style banner-style-three"].sample,
|
||||||
|
image: ["banner-img banner-img-one", "banner-img banner-img-two",
|
||||||
|
"banner-img banner-img-three"].sample,
|
||||||
|
target_url: Rails.application.routes.url_helpers.proposal_path(proposal),
|
||||||
|
post_started_at: rand((Time.now - 1.week) .. (Time.now - 1.day)),
|
||||||
|
post_ended_at: rand((Time.now - 1.day) .. (Time.now + 1.week)),
|
||||||
|
created_at: rand((Time.now - 1.week) .. Time.now))
|
||||||
|
puts " #{banner.title}"
|
||||||
|
end
|
||||||
|
|||||||
19
db/migrate/20160518141543_create_banners.rb
Normal file
19
db/migrate/20160518141543_create_banners.rb
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
class CreateBanners < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :banners do |t|
|
||||||
|
t.string :title, limit: 80
|
||||||
|
t.string :description
|
||||||
|
t.string :target_url
|
||||||
|
t.string :style
|
||||||
|
t.string :image
|
||||||
|
t.date :post_started_at
|
||||||
|
t.date :post_ended_at
|
||||||
|
t.datetime :hidden_at
|
||||||
|
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :banners, :hidden_at
|
||||||
|
end
|
||||||
|
end
|
||||||
17
db/schema.rb
17
db/schema.rb
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20160510161858) do
|
ActiveRecord::Schema.define(version: 20160518141543) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -63,6 +63,21 @@ ActiveRecord::Schema.define(version: 20160510161858) do
|
|||||||
add_index "annotations", ["legislation_id"], name: "index_annotations_on_legislation_id", using: :btree
|
add_index "annotations", ["legislation_id"], name: "index_annotations_on_legislation_id", using: :btree
|
||||||
add_index "annotations", ["user_id"], name: "index_annotations_on_user_id", using: :btree
|
add_index "annotations", ["user_id"], name: "index_annotations_on_user_id", using: :btree
|
||||||
|
|
||||||
|
create_table "banners", force: :cascade do |t|
|
||||||
|
t.string "title", limit: 80
|
||||||
|
t.string "description"
|
||||||
|
t.string "target_url"
|
||||||
|
t.string "style"
|
||||||
|
t.string "image"
|
||||||
|
t.date "post_started_at"
|
||||||
|
t.date "post_ended_at"
|
||||||
|
t.datetime "hidden_at"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "banners", ["hidden_at"], name: "index_banners_on_hidden_at", using: :btree
|
||||||
|
|
||||||
create_table "campaigns", force: :cascade do |t|
|
create_table "campaigns", force: :cascade do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "track_id"
|
t.string "track_id"
|
||||||
|
|||||||
10
db/seeds.rb
10
db/seeds.rb
@@ -64,3 +64,13 @@ Setting['feature.public_stats'] = true
|
|||||||
|
|
||||||
# Spending proposals feature flags
|
# Spending proposals feature flags
|
||||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||||
|
|
||||||
|
# Banner styles
|
||||||
|
Setting['banner-style.banner-style-one'] = "Banner style 1"
|
||||||
|
Setting['banner-style.banner-style-two'] = "Banner style 2"
|
||||||
|
Setting['banner-style.banner-style-three'] = "Banner style 3"
|
||||||
|
|
||||||
|
# Banner images
|
||||||
|
Setting['banner-img.banner-img-one'] = "Banner image 1"
|
||||||
|
Setting['banner-img.banner-img-two'] = "Banner image 2"
|
||||||
|
Setting['banner-img.banner-img-three'] = "Banner image 3"
|
||||||
|
|||||||
@@ -316,4 +316,14 @@ FactoryGirl.define do
|
|||||||
sequence(:name) { |n| "District #{n}" }
|
sequence(:name) { |n| "District #{n}" }
|
||||||
census_code { '01' }
|
census_code { '01' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :banner do
|
||||||
|
sequence(:title) { |n| "Banner title #{n}" }
|
||||||
|
sequence(:description) { |n| "This is the text of Banner #{n}" }
|
||||||
|
style {["banner-style-one", "banner-style-two", "banner-style-three"].sample}
|
||||||
|
image {["banner.banner-img-one", "banner.banner-img-two", "banner.banner-img-three"].sample}
|
||||||
|
target_url {["/proposals", "/debates" ].sample}
|
||||||
|
post_started_at Time.now - 7.days
|
||||||
|
post_ended_at Time.now + 7.days
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
154
spec/features/admin/banners_spec.rb
Normal file
154
spec/features/admin/banners_spec.rb
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
feature 'Admin banners magement' do
|
||||||
|
background do
|
||||||
|
login_as(create(:administrator).user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Index" do
|
||||||
|
background do
|
||||||
|
@banner1 = create(:banner, title: "Banner number one",
|
||||||
|
description: "This is the text of banner number one and is not active yet",
|
||||||
|
target_url: "http://www.url.com",
|
||||||
|
style: "banner-style.banner-one",
|
||||||
|
image: "banner-img.banner-one",
|
||||||
|
post_started_at: (Time.now + 4.days),
|
||||||
|
post_ended_at: (Time.now + 10.days))
|
||||||
|
|
||||||
|
@banner2 = create(:banner, title: "Banner number two",
|
||||||
|
description: "This is the text of banner number two and is not longer active",
|
||||||
|
target_url: "http://www.url.com",
|
||||||
|
style: "banner-style.banner-two",
|
||||||
|
image: "banner-img.banner-two",
|
||||||
|
post_started_at: (Time.now - 10.days),
|
||||||
|
post_ended_at: (Time.now - 3.days))
|
||||||
|
|
||||||
|
@banner3 = create(:banner, title: "Banner number three",
|
||||||
|
description: "This is the text of banner number three and has style banner-three",
|
||||||
|
target_url: "http://www.url.com",
|
||||||
|
style: "banner-style.banner-three",
|
||||||
|
image: "banner-img.banner-three",
|
||||||
|
post_started_at: (Time.now - 1.days),
|
||||||
|
post_ended_at: (Time.now + 10.days))
|
||||||
|
|
||||||
|
@banner4 = create(:banner, title: "Banner number four",
|
||||||
|
description: "This is the text of banner number four and has style banner-one",
|
||||||
|
target_url: "http://www.url.com",
|
||||||
|
style: "banner-style.banner-one",
|
||||||
|
image: "banner-img.banner-one",
|
||||||
|
post_started_at: (DateTime.now - 10.days),
|
||||||
|
post_ended_at: (DateTime.now + 10.days))
|
||||||
|
|
||||||
|
@banner5 = create(:banner, title: "Banner number five",
|
||||||
|
description: "This is the text of banner number five and has style banner-two",
|
||||||
|
target_url: "http://www.url.com",
|
||||||
|
style: "banner-style.banner-one",
|
||||||
|
image: "banner-img.banner-one",
|
||||||
|
post_started_at: (DateTime.now - 10.days),
|
||||||
|
post_ended_at: (DateTime.now + 10.days))
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Index show active banners' do
|
||||||
|
visit admin_banners_path(filter: 'with_active')
|
||||||
|
expect(page).to have_content("There are 3 banners")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Index show inactive banners' do
|
||||||
|
visit admin_banners_path(filter: 'with_inactive')
|
||||||
|
expect(page).to have_content("There are 2 banners")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Index show all banners' do
|
||||||
|
visit admin_banners_path
|
||||||
|
expect(page).to have_content("There are 5 banners")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Banners publication is listed on admin menu' do
|
||||||
|
visit admin_root_path
|
||||||
|
|
||||||
|
within('#admin_menu') do
|
||||||
|
expect(page).to have_link "Manage banners"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Publish a banner' do
|
||||||
|
visit admin_root_path
|
||||||
|
click_link "Manage banners"
|
||||||
|
|
||||||
|
click_link "Create banner"
|
||||||
|
|
||||||
|
select 'Banner style 1', from: 'banner_style'
|
||||||
|
select 'Banner image 2', from: 'banner_image'
|
||||||
|
fill_in 'banner_title', with: 'Such banner'
|
||||||
|
fill_in 'banner_description', with: 'many text wow link'
|
||||||
|
fill_in 'banner_target_url', with: 'https://decide.madrid.es'
|
||||||
|
last_week = Time.now - 7.days
|
||||||
|
next_week = Time.now + 7.days
|
||||||
|
fill_in 'post_started_at', with: last_week.strftime("%d/%m/%Y")
|
||||||
|
fill_in 'post_ended_at', with: next_week.strftime("%d/%m/%Y")
|
||||||
|
|
||||||
|
click_button 'Save changes'
|
||||||
|
|
||||||
|
expect(page).to have_content 'Such banner'
|
||||||
|
|
||||||
|
visit proposals_path
|
||||||
|
|
||||||
|
expect(page).to have_content 'Such banner'
|
||||||
|
expect(page).to have_link 'Such banner many text wow link', href: 'https://decide.madrid.es'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Edit banner with live refresh', :js do
|
||||||
|
banner1 = create(:banner, title: 'Hello',
|
||||||
|
description: 'Wrong text',
|
||||||
|
target_url: 'http://www.url.com',
|
||||||
|
style: 'banner-style.banner-one',
|
||||||
|
image: 'banner-img.banner-one',
|
||||||
|
post_started_at: (Time.now + 4.days),
|
||||||
|
post_ended_at: (Time.now + 10.days))
|
||||||
|
|
||||||
|
visit admin_root_path
|
||||||
|
click_link "Manage banners"
|
||||||
|
|
||||||
|
click_link "Edit banner"
|
||||||
|
|
||||||
|
select 'Banner style 1', from: 'banner_style'
|
||||||
|
select 'Banner image 2', from: 'banner_image'
|
||||||
|
fill_in 'banner_title', with: 'Modified title'
|
||||||
|
fill_in 'banner_description', with: 'Edited text'
|
||||||
|
|
||||||
|
within('div#js-banner-style') do
|
||||||
|
expect(page).to have_selector('h2', :text => 'Modified title')
|
||||||
|
expect(page).to have_selector('h3', :text => 'Edited text')
|
||||||
|
end
|
||||||
|
|
||||||
|
click_button 'Save changes'
|
||||||
|
|
||||||
|
visit admin_banners_path
|
||||||
|
expect(page).to have_content 'Modified title'
|
||||||
|
expect(page).to have_content 'Edited text'
|
||||||
|
|
||||||
|
expect(page).to_not have_content 'Hello'
|
||||||
|
expect(page).to_not have_content 'Wrong text'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Delete a banner' do
|
||||||
|
banner1 = create(:banner, title: 'Ugly banner',
|
||||||
|
description: 'Bad text',
|
||||||
|
target_url: 'http://www.url.com',
|
||||||
|
style: 'banner-style.banner-one',
|
||||||
|
image: 'banner-img.banner-one',
|
||||||
|
post_started_at: (Time.now + 4.days),
|
||||||
|
post_ended_at: (Time.now + 10.days))
|
||||||
|
visit admin_root_path
|
||||||
|
click_link "Manage banners"
|
||||||
|
|
||||||
|
expect(page).to have_content 'Ugly banner'
|
||||||
|
|
||||||
|
click_link "Delete banner"
|
||||||
|
|
||||||
|
visit admin_root_path
|
||||||
|
expect(page).to_not have_content 'Ugly banner'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -54,4 +54,28 @@ describe Setting do
|
|||||||
expect(setting.enabled?).to eq false
|
expect(setting.enabled?).to eq false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#banner_style?" do
|
||||||
|
it "should be true if key starts with 'banner-style.'" do
|
||||||
|
setting = Setting.create(key: 'banner-style.whatever')
|
||||||
|
expect(setting.banner_style?).to eq true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be false if key does not start with 'banner-style.'" do
|
||||||
|
setting = Setting.create(key: 'whatever')
|
||||||
|
expect(setting.banner_style?).to eq false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#banner_img?" do
|
||||||
|
it "should be true if key starts with 'banner-img.'" do
|
||||||
|
setting = Setting.create(key: 'banner-img.whatever')
|
||||||
|
expect(setting.banner_img?).to eq true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be false if key does not start with 'banner-img.'" do
|
||||||
|
setting = Setting.create(key: 'whatever')
|
||||||
|
expect(setting.banner_img?).to eq false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user