tb_banners 1.2.0.beta1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.markdown +9 -14
- data/Rakefile +2 -5
- data/app/assets/javascripts/admin/banners/banner_sets.js +4 -1
- data/app/assets/javascripts/admin/banners/banners.js +49 -56
- data/app/assets/stylesheets/admin/banners/banners.css.scss +6 -1
- data/app/controllers/admin/banner_sets_controller.rb +15 -23
- data/app/controllers/admin/banners_controller.rb +32 -61
- data/app/helpers/spud_banners_helper.rb +24 -19
- data/app/models/spud_banner.rb +33 -20
- data/app/models/spud_banner_set.rb +16 -19
- data/app/views/admin/banner_sets/index.html.erb +1 -1
- data/app/views/admin/banner_sets/show.html.erb +2 -1
- data/app/views/admin/banners/_banner.html.erb +4 -1
- data/app/views/admin/banners/_form.html.erb +3 -5
- data/db/migrate/20121116195139_create_spud_banners.rb +1 -1
- data/db/migrate/20121116195312_create_spud_banner_sets.rb +1 -1
- data/db/migrate/20130614132846_add_rich_text_to_spud_banners.rb +1 -1
- data/db/migrate/20140721142719_add_start_and_end_dates_to_spud_banners.rb +1 -1
- data/lib/spud_banners/configuration.rb +6 -5
- data/lib/spud_banners/engine.rb +13 -11
- data/lib/spud_banners/version.rb +1 -1
- data/lib/tb_banners.rb +1 -2
- data/spec/controllers/admin/banner_sets_controller_spec.rb +57 -58
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/config/application.rb +2 -3
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/config/environments/test.rb +3 -4
- data/spec/dummy/config/initializers/secret_token.rb +0 -1
- data/spec/dummy/db/migrate/20121127192246_create_spud_admin_permissions.spud_core.rb +1 -1
- data/spec/dummy/db/migrate/20121127192247_create_spud_users.spud_core.rb +13 -13
- data/spec/dummy/db/migrate/20121127192248_add_time_zone_to_spud_user.spud_core.rb +1 -2
- data/spec/dummy/db/migrate/20121127192249_add_scope_to_spud_admin_permissions.spud_core.rb +1 -2
- data/spec/dummy/db/migrate/20121127192250_create_spud_user_settings.spud_core.rb +1 -1
- data/spec/dummy/db/migrate/20130920154442_create_spud_roles.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20130920154443_create_spud_permissions.tb_core.rb +4 -4
- data/spec/dummy/db/migrate/20130920154444_create_spud_role_permissions.tb_core.rb +3 -3
- data/spec/dummy/db/migrate/20130920154445_drop_spud_admin_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20160310164644_add_requires_password_change_to_spud_users.tb_core.rb +6 -0
- data/spec/dummy/db/schema.rb +70 -84
- data/spec/dummy/script/rails +2 -2
- data/spec/factories/spud_banner_sets.rb +9 -0
- data/spec/factories/spud_banners.rb +7 -0
- data/spec/models/spud_banner_spec.rb +27 -0
- data/spec/rails_helper.rb +81 -0
- data/spec/spec_helper.rb +77 -34
- metadata +79 -109
- data/app/views/admin/banners/legacy.js.erb +0 -5
- data/lib/spud_banners/liquid_tags.rb +0 -31
- data/spec/dummy/db/migrate/20130920154446_create_spud_banners.tb_banners.rb +0 -16
- data/spec/dummy/db/migrate/20130920154447_create_spud_banner_sets.tb_banners.rb +0 -13
- data/spec/dummy/db/migrate/20130920154448_add_rich_text_to_spud_banners.tb_banners.rb +0 -7
- data/spec/dummy/db/migrate/20140120174546_create_tb_liquid_spud_liquid_tags.tb_liquid.rb +0 -13
- data/spec/support/authlogic_helper.rb +0 -2
@@ -1,23 +1,24 @@
|
|
1
1
|
module SpudBannersHelper
|
2
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
2
3
|
|
3
4
|
# Returns banner html for a given identifier
|
4
|
-
# Generated HTML will be cached if your application uses fragment caching
|
5
5
|
#
|
6
|
-
# * set_or_identifier: A reference to a SpudBannerSet,
|
6
|
+
# * set_or_identifier: A reference to a SpudBannerSet,
|
7
|
+
# or the name of a known banner set passed as a symbol (ie, :home)
|
7
8
|
# * options:
|
8
9
|
# - limit: Max number of banners to return
|
9
10
|
# - background_image: Pass true to return the banners as CSS background-image properties rather than <img/> tags
|
10
11
|
#
|
11
12
|
def spud_banners_for_set(set_or_identifier, options = {})
|
12
|
-
if set_or_identifier.is_a?(SpudBannerSet)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
banner_set = if set_or_identifier.is_a?(SpudBannerSet)
|
14
|
+
set_or_identifier
|
15
|
+
else
|
16
|
+
SpudBannerSet.find_with_identifier(set_or_identifier)
|
17
|
+
end
|
18
|
+
|
17
19
|
return '' if banner_set.blank?
|
18
|
-
|
19
|
-
|
20
|
-
end
|
20
|
+
|
21
|
+
spud_banners_set_tag(banner_set, options)
|
21
22
|
end
|
22
23
|
|
23
24
|
# Returns banner html for a given banner_set
|
@@ -39,13 +40,16 @@ module SpudBannersHelper
|
|
39
40
|
content_tag(:div, :class => "spud-banner-set #{options[:wrapper_class]}", 'data-id' => banner_set.id) do
|
40
41
|
banners_query.map do |banner|
|
41
42
|
if background_image
|
42
|
-
concat(content_tag(:div,
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
concat(content_tag(:div,
|
44
|
+
class: "spud-banner #{options[:banner_class]}",
|
45
|
+
style: "background-image:url('#{banner.banner.url(:banner)}');",
|
46
|
+
'data-id' => banner.id) do
|
47
|
+
content_tag :div, raw(banner.rich_text), class: 'spud-banner-rich-text' if banner.rich_text
|
48
|
+
end)
|
47
49
|
else
|
48
|
-
concat(content_tag(:div, :class => "spud-banner #{options[:banner_class]}", 'data-id' => banner.id)
|
50
|
+
concat(content_tag(:div, :class => "spud-banner #{options[:banner_class]}", 'data-id' => banner.id) do
|
51
|
+
spud_banner_tag(banner, options)
|
52
|
+
end)
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
@@ -55,11 +59,11 @@ module SpudBannersHelper
|
|
55
59
|
# Returns an HTML tag for a single banner
|
56
60
|
# May return either an <img/> or an <a/> depending on the banner
|
57
61
|
#
|
58
|
-
def spud_banner_tag(banner,
|
62
|
+
def spud_banner_tag(banner, _options = {})
|
59
63
|
if banner.link_to.blank?
|
60
64
|
spud_banner_image_tag(banner)
|
61
65
|
else
|
62
|
-
link_to(banner.link_to, :
|
66
|
+
link_to(banner.link_to, target: banner.link_target) do
|
63
67
|
spud_banner_image_tag(banner)
|
64
68
|
end
|
65
69
|
end
|
@@ -68,7 +72,8 @@ module SpudBannersHelper
|
|
68
72
|
# Returns an HTML <img/> tag for a single banner
|
69
73
|
#
|
70
74
|
def spud_banner_image_tag(banner)
|
71
|
-
image_tag(banner.banner.url(:banner), :
|
75
|
+
image_tag(banner.banner.url(:banner), alt: banner.alt, title: banner.title)
|
72
76
|
end
|
73
77
|
|
78
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
74
79
|
end
|
data/app/models/spud_banner.rb
CHANGED
@@ -1,33 +1,46 @@
|
|
1
1
|
class SpudBanner < ActiveRecord::Base
|
2
|
-
belongs_to :owner,
|
2
|
+
belongs_to :owner,
|
3
|
+
class_name: SpudBannerSet.to_s,
|
4
|
+
foreign_key: :spud_banner_set_id,
|
5
|
+
inverse_of: :banners,
|
6
|
+
touch: true
|
3
7
|
|
4
|
-
scope :active,
|
5
|
-
|
8
|
+
scope :active, lambda {
|
9
|
+
t = Time.zone.today
|
10
|
+
start_date = arel_table[:start_date]
|
11
|
+
end_date = arel_table[:end_date]
|
12
|
+
|
13
|
+
where(
|
14
|
+
start_date.eq(nil).or(start_date.lteq(t)).and(
|
15
|
+
end_date.eq(nil).or(end_date.gteq(t))
|
16
|
+
)
|
17
|
+
)
|
6
18
|
}
|
7
19
|
|
8
|
-
has_attached_file :banner,
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
20
|
+
has_attached_file :banner,
|
21
|
+
styles: ->(attachment) { attachment.instance.dynamic_styles },
|
22
|
+
convert_options: {
|
23
|
+
tiny: '-strip -density 72x72',
|
24
|
+
banner: '-strip -density 72x72'
|
13
25
|
},
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
26
|
+
storage: Spud::Banners.paperclip_storage,
|
27
|
+
s3_credentials: Spud::Banners.s3_credentials,
|
28
|
+
s3_protocol: Spud::Banners.s3_protocol,
|
29
|
+
url: Spud::Banners.storage_url,
|
30
|
+
path: Spud::Banners.storage_path
|
18
31
|
|
19
32
|
validates_attachment :banner,
|
20
|
-
:
|
21
|
-
:
|
33
|
+
presence: true,
|
34
|
+
content_type: { content_type: ['image/jpg', 'image/jpeg', 'image/png'] }
|
22
35
|
|
23
36
|
def dynamic_styles
|
24
37
|
styles = {
|
25
|
-
:
|
38
|
+
tiny: '150x150'
|
26
39
|
}
|
27
40
|
owner_style = nil
|
28
|
-
if
|
29
|
-
owner_style = "#{
|
30
|
-
owner_style += '#' if
|
41
|
+
if owner
|
42
|
+
owner_style = "#{owner.width}x#{owner.height}"
|
43
|
+
owner_style += '#' if owner.cropped
|
31
44
|
styles[:banner] = owner_style
|
32
45
|
end
|
33
46
|
return styles
|
@@ -37,8 +50,8 @@ class SpudBanner < ActiveRecord::Base
|
|
37
50
|
return owner.name
|
38
51
|
end
|
39
52
|
|
40
|
-
def
|
41
|
-
return end_date.present? && end_date <
|
53
|
+
def expired?
|
54
|
+
return end_date.present? && end_date < Time.zone.today
|
42
55
|
end
|
43
56
|
|
44
57
|
end
|
@@ -1,27 +1,26 @@
|
|
1
1
|
class SpudBannerSet < ActiveRecord::Base
|
2
|
-
has_many :banners, ->{ order(
|
2
|
+
has_many :banners, -> { order(sort_order: :asc) },
|
3
|
+
class_name: SpudBanner.to_s, dependent: :destroy, inverse_of: :owner
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
acts_as_spud_liquid_tag :spud_banner_set, :name
|
5
|
+
validates :name, presence: true
|
6
|
+
validates :name, uniqueness: true
|
7
|
+
validates :width, :height, numericality: true
|
9
8
|
|
10
9
|
after_update :check_for_dimension_change
|
11
10
|
|
12
|
-
def self.
|
13
|
-
if identifier.class == String
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
def self.find_with_identifier(identifier)
|
12
|
+
banner_set = if identifier.class == String
|
13
|
+
SpudBannerSet.find_by(name: identifier.strip)
|
14
|
+
elsif identifier.class == Symbol
|
15
|
+
SpudBannerSet.find_by(name: identifier.to_s.titleize)
|
16
|
+
else
|
17
|
+
SpudBannerSet.find(identifier)
|
18
|
+
end
|
20
19
|
return banner_set
|
21
20
|
end
|
22
21
|
|
23
22
|
def reprocess_banners!
|
24
|
-
|
23
|
+
banners.each do |banner|
|
25
24
|
banner.banner.reprocess!
|
26
25
|
end
|
27
26
|
end
|
@@ -30,12 +29,10 @@ class SpudBannerSet < ActiveRecord::Base
|
|
30
29
|
return name
|
31
30
|
end
|
32
31
|
|
33
|
-
private
|
32
|
+
private
|
34
33
|
|
35
34
|
def check_for_dimension_change
|
36
|
-
if
|
37
|
-
self.reprocess_banners!
|
38
|
-
end
|
35
|
+
reprocess_banners! if saved_change_to_height? || saved_change_to_width? || saved_change_to_cropped?
|
39
36
|
end
|
40
37
|
|
41
38
|
end
|
@@ -6,6 +6,7 @@
|
|
6
6
|
<table class="table table-striped table-hover">
|
7
7
|
<thead>
|
8
8
|
<tr>
|
9
|
+
<th> </th>
|
9
10
|
<th>Banner</th>
|
10
11
|
<th>Start Date</th>
|
11
12
|
<th>End Date</th>
|
@@ -22,5 +23,5 @@
|
|
22
23
|
</div>
|
23
24
|
|
24
25
|
<script>
|
25
|
-
$(document).ready(
|
26
|
+
$(document).ready(tb.banners.init);
|
26
27
|
</script>
|
@@ -1,4 +1,7 @@
|
|
1
1
|
<%= content_tag :tr, 'data-id' => banner.id, :class => 'admin-banner-set-item' do %>
|
2
|
+
<td>
|
3
|
+
<span class="glyphicon glyphicon-sort" aria-hidden="true"></span>
|
4
|
+
</td>
|
2
5
|
<td width="200">
|
3
6
|
<%= link_to banner.banner.url(:banner), :target => :blank do %>
|
4
7
|
<%= image_tag banner.banner.url(:tiny) %>
|
@@ -7,7 +10,7 @@
|
|
7
10
|
<td><%= banner.start_date.try(:strftime, '%m/%d/%Y') %></td>
|
8
11
|
<td class="table-actions">
|
9
12
|
<%= banner.end_date.try(:strftime, '%m/%d/%Y') %>
|
10
|
-
<% if banner.
|
13
|
+
<% if banner.expired? %>
|
11
14
|
<span class="label">Expired</span>
|
12
15
|
<% end %>
|
13
16
|
</td>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for @banner, :url => path, :builder => TbCore::FormBuilder, :html => {:class => 'admin-banner-form'
|
1
|
+
<%= form_for @banner, :url => path, :builder => TbCore::FormBuilder, :html => { :class => 'admin-banner-form' } do |f| %>
|
2
2
|
|
3
3
|
<%= tb_form_errors(f.object) %>
|
4
4
|
|
@@ -47,13 +47,13 @@
|
|
47
47
|
<div class="form-group">
|
48
48
|
<%= f.label :start_date, 'Start Date', :class => 'control-label' %>
|
49
49
|
<div class="controls controls-banner-date-selects">
|
50
|
-
<%= f.date_select :start_date, :start_year =>
|
50
|
+
<%= f.date_select :start_date, :start_year => Time.zone.today.year %>
|
51
51
|
</div>
|
52
52
|
</div>
|
53
53
|
<div class="form-group">
|
54
54
|
<%= f.label :end_date, 'End Date', :class => 'control-label' %>
|
55
55
|
<div class="controls controls-banner-date-selects">
|
56
|
-
<%= f.date_select :end_date, :include_blank => true, :start_year =>
|
56
|
+
<%= f.date_select :end_date, :include_blank => true, :start_year => Time.zone.today.year %>
|
57
57
|
<span class="help-block">Leave blank to never expire</span>
|
58
58
|
</div>
|
59
59
|
</div>
|
@@ -63,5 +63,3 @@
|
|
63
63
|
</div>
|
64
64
|
|
65
65
|
<% end %>
|
66
|
-
|
67
|
-
<iframe id="admin-banner-upload-target" name="admin-banner-upload-target" style="display:none;"></iframe>
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Spud
|
2
2
|
module Banners
|
3
3
|
include ActiveSupport::Configurable
|
4
|
-
config_accessor :paperclip_storage, :s3_credentials, :storage_path, :storage_url
|
4
|
+
config_accessor :paperclip_storage, :s3_credentials, :storage_path, :storage_url, :s3_protocol
|
5
5
|
self.paperclip_storage = :filesystem
|
6
|
-
self.s3_credentials =
|
7
|
-
self.
|
8
|
-
self.
|
6
|
+
self.s3_credentials = './config/s3.yml'
|
7
|
+
self.s3_protocol = 'https'
|
8
|
+
self.storage_path = ':rails_root/public/system/spud_banners/:id/:style/:basename.:extension'
|
9
|
+
self.storage_url = '/system/spud_banners/:id/:style/:basename.:extension'
|
9
10
|
end
|
10
|
-
end
|
11
|
+
end
|
data/lib/spud_banners/engine.rb
CHANGED
@@ -1,25 +1,27 @@
|
|
1
1
|
require 'tb_core'
|
2
2
|
require 'paperclip'
|
3
|
-
require 'tb_liquid'
|
4
3
|
|
5
4
|
module Spud
|
6
5
|
module Banners
|
7
6
|
class Engine < Rails::Engine
|
8
7
|
engine_name :tb_banners
|
9
|
-
|
10
|
-
Spud::Core.append_admin_javascripts('admin/banners/application')
|
8
|
+
|
11
9
|
initializer :admin do
|
12
|
-
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
10
|
+
TbCore.config.admin_applications += [{
|
11
|
+
name: 'Banner Sets',
|
12
|
+
thumbnail: 'admin/banners/banners.png',
|
13
|
+
retina: true,
|
14
|
+
url: '/admin/banner_sets',
|
15
|
+
order: 120
|
18
16
|
}]
|
19
17
|
end
|
20
|
-
|
21
|
-
|
18
|
+
|
19
|
+
initializer 'tb_banners.assets' do
|
20
|
+
TbCore.append_admin_stylesheets('admin/banners/application')
|
21
|
+
TbCore.append_admin_javascripts('admin/banners/application')
|
22
|
+
Rails.application.config.assets.precompile += ['admin/banners/banners.png']
|
22
23
|
end
|
24
|
+
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
data/lib/spud_banners/version.rb
CHANGED
data/lib/tb_banners.rb
CHANGED
@@ -1,100 +1,99 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
|
-
describe Admin::BannerSetsController do
|
3
|
+
describe Admin::BannerSetsController, type: 'controller' do
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
activate_authlogic
|
7
|
-
u = SpudUser.new(:
|
7
|
+
u = SpudUser.new(login: 'testuser', email: 'test@testuser.com', password: 'test', password_confirmation: 'test')
|
8
8
|
u.super_admin = true
|
9
9
|
u.save
|
10
10
|
@user = SpudUserSession.create(u)
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
14
|
-
it
|
15
|
-
5.times do |
|
16
|
-
|
13
|
+
describe 'index' do
|
14
|
+
it 'should return an array of banner sets' do
|
15
|
+
5.times do |_x|
|
16
|
+
FactoryBot.create(:spud_banner_set)
|
17
17
|
end
|
18
18
|
get :index
|
19
|
-
assigns(:banner_sets).count.
|
19
|
+
expect(assigns(:banner_sets).count).to be > 1
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it
|
25
|
-
banner_set =
|
26
|
-
get :show, :id
|
27
|
-
assigns(:banner_set).
|
28
|
-
response.
|
23
|
+
describe 'show' do
|
24
|
+
it 'should respond with a banner set' do
|
25
|
+
banner_set = FactoryBot.create(:spud_banner_set)
|
26
|
+
get :show, params: { id: banner_set.id }
|
27
|
+
expect(assigns(:banner_set)).to eq(banner_set)
|
28
|
+
expect(response).to be_success
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
32
|
-
get :show, :id
|
33
|
-
assigns(:banner_set).
|
34
|
-
response.
|
31
|
+
it 'should return a 404 if banner set is not found' do
|
32
|
+
get :show, params: { id: -1 }
|
33
|
+
expect(assigns(:banner_set)).to be_blank
|
34
|
+
expect(response.status).to eq(404)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
39
|
-
it
|
38
|
+
describe 'new' do
|
39
|
+
it 'should respond with a banner set' do
|
40
40
|
get :new
|
41
|
-
|
42
|
-
response.should be_success
|
41
|
+
expect(response).to be_success
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
describe
|
47
|
-
it
|
48
|
-
|
49
|
-
post :create, :spud_banner_set
|
50
|
-
|
51
|
-
response.
|
45
|
+
describe 'create' do
|
46
|
+
it 'should respond with a banner set' do
|
47
|
+
expect do
|
48
|
+
post :create, params: { spud_banner_set: FactoryBot.attributes_for(:spud_banner_set) }
|
49
|
+
end.to change(SpudBannerSet, :count).by(1)
|
50
|
+
expect(response).to be_success
|
52
51
|
end
|
53
52
|
|
54
|
-
it
|
55
|
-
|
56
|
-
post :create, :spud_banner_set
|
57
|
-
|
53
|
+
it 'should respond unsuccessfully if the banner set is invalid' do
|
54
|
+
expect do
|
55
|
+
post :create, params: { spud_banner_set: { name: '', width: 'lorem', height: 'ipsum' } }
|
56
|
+
end.to_not change(SpudBannerSet, :count)
|
58
57
|
assert_response 422
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
62
|
-
describe
|
63
|
-
it
|
64
|
-
banner_set =
|
65
|
-
get :edit, :id
|
66
|
-
assigns(:banner_set).
|
67
|
-
response.
|
61
|
+
describe 'edit' do
|
62
|
+
it 'should respond with a banner set' do
|
63
|
+
banner_set = FactoryBot.create(:spud_banner_set)
|
64
|
+
get :edit, params: { id: banner_set.id }
|
65
|
+
expect(assigns(:banner_set)).to eq(banner_set)
|
66
|
+
expect(response).to be_success
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
71
|
-
describe
|
72
|
-
it
|
73
|
-
banner_set =
|
74
|
-
new_name =
|
75
|
-
|
76
|
-
put :update, :id
|
70
|
+
describe 'update' do
|
71
|
+
it 'should update the banner set' do
|
72
|
+
banner_set = FactoryBot.create(:spud_banner_set)
|
73
|
+
new_name = 'Updated Set Name'
|
74
|
+
expect do
|
75
|
+
put :update, params: { id: banner_set.id, spud_banner_set: { name: new_name } }
|
77
76
|
banner_set.reload
|
78
|
-
|
77
|
+
end.to change(banner_set, :name).to(new_name)
|
79
78
|
end
|
80
79
|
|
81
|
-
it
|
82
|
-
banner_set =
|
83
|
-
|
84
|
-
put :update, :id
|
85
|
-
|
80
|
+
it 'should respond unsuccessfully if the updated banner set is invalid' do
|
81
|
+
banner_set = FactoryBot.create(:spud_banner_set)
|
82
|
+
expect do
|
83
|
+
put :update, params: { id: banner_set.id, spud_banner_set: { name: '', width: 'lorem', height: 'ipsum' } }
|
84
|
+
end.to_not change(SpudBannerSet, :count)
|
86
85
|
assert_response 422
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
90
|
-
describe
|
91
|
-
it
|
92
|
-
banner_set =
|
93
|
-
|
94
|
-
delete :destroy, :id
|
95
|
-
|
96
|
-
response.
|
89
|
+
describe 'destroy' do
|
90
|
+
it 'should destroy the banner set and respond successfully' do
|
91
|
+
banner_set = FactoryBot.create(:spud_banner_set)
|
92
|
+
expect do
|
93
|
+
delete :destroy, params: { id: banner_set.id }
|
94
|
+
end.to change(SpudBannerSet, :count).by(-1)
|
95
|
+
expect(response).to be_success
|
97
96
|
end
|
98
97
|
end
|
99
98
|
|
100
|
-
end
|
99
|
+
end
|