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.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/README.markdown +9 -14
  3. data/Rakefile +2 -5
  4. data/app/assets/javascripts/admin/banners/banner_sets.js +4 -1
  5. data/app/assets/javascripts/admin/banners/banners.js +49 -56
  6. data/app/assets/stylesheets/admin/banners/banners.css.scss +6 -1
  7. data/app/controllers/admin/banner_sets_controller.rb +15 -23
  8. data/app/controllers/admin/banners_controller.rb +32 -61
  9. data/app/helpers/spud_banners_helper.rb +24 -19
  10. data/app/models/spud_banner.rb +33 -20
  11. data/app/models/spud_banner_set.rb +16 -19
  12. data/app/views/admin/banner_sets/index.html.erb +1 -1
  13. data/app/views/admin/banner_sets/show.html.erb +2 -1
  14. data/app/views/admin/banners/_banner.html.erb +4 -1
  15. data/app/views/admin/banners/_form.html.erb +3 -5
  16. data/db/migrate/20121116195139_create_spud_banners.rb +1 -1
  17. data/db/migrate/20121116195312_create_spud_banner_sets.rb +1 -1
  18. data/db/migrate/20130614132846_add_rich_text_to_spud_banners.rb +1 -1
  19. data/db/migrate/20140721142719_add_start_and_end_dates_to_spud_banners.rb +1 -1
  20. data/lib/spud_banners/configuration.rb +6 -5
  21. data/lib/spud_banners/engine.rb +13 -11
  22. data/lib/spud_banners/version.rb +1 -1
  23. data/lib/tb_banners.rb +1 -2
  24. data/spec/controllers/admin/banner_sets_controller_spec.rb +57 -58
  25. data/spec/dummy/config.ru +1 -1
  26. data/spec/dummy/config/application.rb +2 -3
  27. data/spec/dummy/config/boot.rb +1 -1
  28. data/spec/dummy/config/environments/production.rb +1 -1
  29. data/spec/dummy/config/environments/test.rb +3 -4
  30. data/spec/dummy/config/initializers/secret_token.rb +0 -1
  31. data/spec/dummy/db/migrate/20121127192246_create_spud_admin_permissions.spud_core.rb +1 -1
  32. data/spec/dummy/db/migrate/20121127192247_create_spud_users.spud_core.rb +13 -13
  33. data/spec/dummy/db/migrate/20121127192248_add_time_zone_to_spud_user.spud_core.rb +1 -2
  34. data/spec/dummy/db/migrate/20121127192249_add_scope_to_spud_admin_permissions.spud_core.rb +1 -2
  35. data/spec/dummy/db/migrate/20121127192250_create_spud_user_settings.spud_core.rb +1 -1
  36. data/spec/dummy/db/migrate/20130920154442_create_spud_roles.tb_core.rb +1 -1
  37. data/spec/dummy/db/migrate/20130920154443_create_spud_permissions.tb_core.rb +4 -4
  38. data/spec/dummy/db/migrate/20130920154444_create_spud_role_permissions.tb_core.rb +3 -3
  39. data/spec/dummy/db/migrate/20130920154445_drop_spud_admin_permissions.tb_core.rb +1 -1
  40. data/spec/dummy/db/migrate/20160310164644_add_requires_password_change_to_spud_users.tb_core.rb +6 -0
  41. data/spec/dummy/db/schema.rb +70 -84
  42. data/spec/dummy/script/rails +2 -2
  43. data/spec/factories/spud_banner_sets.rb +9 -0
  44. data/spec/factories/spud_banners.rb +7 -0
  45. data/spec/models/spud_banner_spec.rb +27 -0
  46. data/spec/rails_helper.rb +81 -0
  47. data/spec/spec_helper.rb +77 -34
  48. metadata +79 -109
  49. data/app/views/admin/banners/legacy.js.erb +0 -5
  50. data/lib/spud_banners/liquid_tags.rb +0 -31
  51. data/spec/dummy/db/migrate/20130920154446_create_spud_banners.tb_banners.rb +0 -16
  52. data/spec/dummy/db/migrate/20130920154447_create_spud_banner_sets.tb_banners.rb +0 -13
  53. data/spec/dummy/db/migrate/20130920154448_add_rich_text_to_spud_banners.tb_banners.rb +0 -7
  54. data/spec/dummy/db/migrate/20140120174546_create_tb_liquid_spud_liquid_tags.tb_liquid.rb +0 -13
  55. 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, or the name of a known banner set passed as a symbol (ie, :home)
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
- banner_set = set_or_identifier
14
- else
15
- banner_set = SpudBannerSet.find_by_identifier(set_or_identifier)
16
- end
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
- cache(banner_set) do
19
- concat spud_banners_set_tag(banner_set, options)
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, :class => "spud-banner #{options[:banner_class]}", 'data-id' => banner.id, :style => "background-image:url('#{banner.banner.url(:banner)}');"){
43
- if banner.rich_text
44
- content_tag :div, raw(banner.rich_text), :class => 'spud-banner-rich-text'
45
- end
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){ spud_banner_tag(banner, options) })
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, options={})
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, :target => banner.link_target) do
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), :alt => banner.alt, :title => banner.title)
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
@@ -1,33 +1,46 @@
1
1
  class SpudBanner < ActiveRecord::Base
2
- belongs_to :owner, :class_name => 'SpudBannerSet', :foreign_key => 'spud_banner_set_id', :inverse_of => :banners, :touch => true
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
- where('(start_date IS NULL OR start_date <= ?) AND (end_date IS NULL OR end_date >= ?)', Date.today, Date.today)
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
- :styles => lambda { |attachment| attachment.instance.dynamic_styles },
10
- :convert_options => {
11
- :tiny => '-strip -density 72x72',
12
- :banner => '-strip -density 72x72'
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
- :storage => Spud::Banners.paperclip_storage,
15
- :s3_credentials => Spud::Banners.s3_credentials,
16
- :url => Spud::Banners.storage_url,
17
- :path => Spud::Banners.storage_path
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
- :presence => true,
21
- :content_type => {:content_type => ['image/jpg', 'image/jpeg', 'image/png']}
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
- :tiny => '150x150'
38
+ tiny: '150x150'
26
39
  }
27
40
  owner_style = nil
28
- if self.owner
29
- owner_style = "#{self.owner.width}x#{self.owner.height}"
30
- owner_style += '#' if self.owner.cropped
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 is_expired?
41
- return end_date.present? && end_date < Date.today
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('sort_order asc') }, :class_name => 'SpudBanner', :dependent => :destroy, :inverse_of => :owner
2
+ has_many :banners, -> { order(sort_order: :asc) },
3
+ class_name: SpudBanner.to_s, dependent: :destroy, inverse_of: :owner
3
4
 
4
- validates_presence_of :name
5
- validates_uniqueness_of :name
6
- validates_numericality_of :width, :height
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.find_by_identifier(identifier)
13
- if identifier.class == String
14
- banner_set = SpudBannerSet.find_by_name(identifier)
15
- elsif identifier.class == Symbol
16
- banner_set = SpudBannerSet.find_by_name(identifier.to_s.titleize)
17
- else
18
- banner_set = SpudBannerSet.find(identifier)
19
- end
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
- self.banners.each do |banner|
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 self.height_changed? || self.width_changed? || self.cropped_changed?
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
@@ -9,6 +9,6 @@
9
9
  </table>
10
10
  </div>
11
11
  <script>
12
- $(document).ready(spud.admin.banner_sets.init);
12
+ $(document).ready(tb.banner_sets.init);
13
13
  </script>
14
14
  <% end %>
@@ -6,6 +6,7 @@
6
6
  <table class="table table-striped table-hover">
7
7
  <thead>
8
8
  <tr>
9
+ <th>&nbsp</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(spud.admin.banners.init);
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.is_expired? %>
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', :target => 'admin-banner-upload-target'} do |f| %>
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 => Date.today.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 => Date.today.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,4 +1,4 @@
1
- class CreateSpudBanners < ActiveRecord::Migration
1
+ class CreateSpudBanners < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :spud_banners do |t|
4
4
  t.integer :spud_banner_set_id, :null => false
@@ -1,4 +1,4 @@
1
- class CreateSpudBannerSets < ActiveRecord::Migration
1
+ class CreateSpudBannerSets < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :spud_banner_sets do |t|
4
4
  t.string :name, :null => false
@@ -1,4 +1,4 @@
1
- class AddRichTextToSpudBanners < ActiveRecord::Migration
1
+ class AddRichTextToSpudBanners < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_banner_sets, :has_rich_text, :boolean, :default => false
4
4
  add_column :spud_banners, :rich_text, :text
@@ -1,4 +1,4 @@
1
- class AddStartAndEndDatesToSpudBanners < ActiveRecord::Migration
1
+ class AddStartAndEndDatesToSpudBanners < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :spud_banners, :start_date, :date
4
4
  add_column :spud_banners, :end_date, :date
@@ -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 = "#{Rails.root}/config/s3.yml"
7
- self.storage_path = ":rails_root/public/system/spud_banners/:id/:style/:basename.:extension"
8
- self.storage_url = "/system/spud_banners/:id/:style/:basename.:extension"
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
@@ -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
- Spud::Core.append_admin_stylesheets('admin/banners/application')
10
- Spud::Core.append_admin_javascripts('admin/banners/application')
8
+
11
9
  initializer :admin do
12
- Spud::Core.config.admin_applications += [{
13
- :name => 'Banner Sets',
14
- :thumbnail => 'admin/banners/banners.png',
15
- :retina => true,
16
- :url => '/admin/banner_sets',
17
- :order => 120
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
- initializer :liquid do
21
- Liquid::Template.register_tag('spud_banner_set', Spud::Banners::BannerSetTag) if defined?(Liquid::Template)
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
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Banners
3
- VERSION = "1.2.0.beta1"
3
+ VERSION = '1.3.2'.freeze
4
4
  end
5
5
  end
@@ -1,7 +1,6 @@
1
1
  module Spud
2
2
  module Banners
3
3
  require 'spud_banners/configuration'
4
- require 'spud_banners/liquid_tags'
5
- require "spud_banners/engine" if defined?(Rails)
4
+ require 'spud_banners/engine' if defined?(Rails)
6
5
  end
7
6
  end
@@ -1,100 +1,99 @@
1
- require 'spec_helper'
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(:login => "testuser",:email => "test@testuser.com",:password => "test",:password_confirmation => "test")
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 :index do
14
- it "should return an array of banner sets" do
15
- 5.times do |x|
16
- banner_set = FactoryGirl.create(:spud_banner_set)
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.should be > 1
19
+ expect(assigns(:banner_sets).count).to be > 1
20
20
  end
21
21
  end
22
22
 
23
- describe :show do
24
- it "should respond with a banner set" do
25
- banner_set = FactoryGirl.create(:spud_banner_set)
26
- get :show, :id => banner_set.id
27
- assigns(:banner_set).should == banner_set
28
- response.should be_success
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 "should redirect if banner set is not found" do
32
- get :show, :id => -1
33
- assigns(:banner_set).should be_blank
34
- response.should redirect_to admin_banner_sets_path
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 :new do
39
- it "should respond with a banner set" do
38
+ describe 'new' do
39
+ it 'should respond with a banner set' do
40
40
  get :new
41
- assigns(:banner_set).should_not be_blank
42
- response.should be_success
41
+ expect(response).to be_success
43
42
  end
44
43
  end
45
44
 
46
- describe :create do
47
- it "should respond with a banner set" do
48
- lambda {
49
- post :create, :spud_banner_set => FactoryGirl.attributes_for(:spud_banner_set)
50
- }.should change(SpudBannerSet, :count).by(1)
51
- response.should be_success
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 "should respond unsuccessfully if the banner set is invalid" do
55
- lambda {
56
- post :create, :spud_banner_set => {:name => '', :width => 'lorem', :height => 'ipsum'}
57
- }.should_not change(SpudBannerSet, :count)
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 :edit do
63
- it "should respond with a banner set" do
64
- banner_set = FactoryGirl.create(:spud_banner_set)
65
- get :edit, :id => banner_set.id
66
- assigns(:banner_set).should == banner_set
67
- response.should be_success
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 :update do
72
- it "should update the banner set" do
73
- banner_set = FactoryGirl.create(:spud_banner_set)
74
- new_name = "Updated Set Name"
75
- lambda {
76
- put :update, :id => banner_set.id, :spud_banner_set => {:name => new_name}
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
- }.should change(banner_set, :name).to(new_name)
77
+ end.to change(banner_set, :name).to(new_name)
79
78
  end
80
79
 
81
- it "should respond unsuccessfully if the updated banner set is invalid" do
82
- banner_set = FactoryGirl.create(:spud_banner_set)
83
- lambda {
84
- put :update, :id => banner_set.id, :spud_banner_set => {:name => '', :width => 'lorem', :height => 'ipsum'}
85
- }.should_not change(SpudBannerSet, :count)
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 :destroy do
91
- it "should destroy the banner set and respond successfully" do
92
- banner_set = FactoryGirl.create(:spud_banner_set)
93
- lambda {
94
- delete :destroy, :id => banner_set.id
95
- }.should change(SpudBannerSet, :count).by(-1)
96
- response.should be_success
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