tb_banners 1.3.beta1 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/README.markdown +0 -1
  3. data/Rakefile +1 -1
  4. data/app/assets/javascripts/admin/banners/banner_sets.js +3 -0
  5. data/app/assets/javascripts/admin/banners/banners.js +9 -12
  6. data/app/assets/stylesheets/admin/banners/banners.css.scss +6 -1
  7. data/app/controllers/admin/banner_sets_controller.rb +9 -13
  8. data/app/controllers/admin/banners_controller.rb +23 -30
  9. data/app/helpers/spud_banners_helper.rb +16 -11
  10. data/app/models/spud_banner.rb +17 -5
  11. data/app/models/spud_banner_set.rb +3 -4
  12. data/app/views/admin/banner_sets/show.html.erb +1 -0
  13. data/app/views/admin/banners/_banner.html.erb +4 -1
  14. data/app/views/admin/banners/_form.html.erb +2 -2
  15. data/db/migrate/20121116195139_create_spud_banners.rb +1 -1
  16. data/db/migrate/20121116195312_create_spud_banner_sets.rb +1 -1
  17. data/db/migrate/20130614132846_add_rich_text_to_spud_banners.rb +1 -1
  18. data/db/migrate/20140721142719_add_start_and_end_dates_to_spud_banners.rb +1 -1
  19. data/lib/spud_banners/configuration.rb +1 -1
  20. data/lib/spud_banners/engine.rb +3 -8
  21. data/lib/spud_banners/version.rb +1 -1
  22. data/lib/tb_banners.rb +0 -1
  23. data/spec/controllers/admin/banner_sets_controller_spec.rb +9 -9
  24. data/spec/dummy/config/initializers/secret_token.rb +0 -1
  25. data/spec/dummy/db/migrate/20121127192246_create_spud_admin_permissions.spud_core.rb +1 -1
  26. data/spec/dummy/db/migrate/20121127192247_create_spud_users.spud_core.rb +1 -1
  27. data/spec/dummy/db/migrate/20121127192248_add_time_zone_to_spud_user.spud_core.rb +1 -1
  28. data/spec/dummy/db/migrate/20121127192249_add_scope_to_spud_admin_permissions.spud_core.rb +1 -1
  29. data/spec/dummy/db/migrate/20121127192250_create_spud_user_settings.spud_core.rb +1 -1
  30. data/spec/dummy/db/migrate/20130920154442_create_spud_roles.tb_core.rb +1 -1
  31. data/spec/dummy/db/migrate/20130920154443_create_spud_permissions.tb_core.rb +1 -1
  32. data/spec/dummy/db/migrate/20130920154444_create_spud_role_permissions.tb_core.rb +1 -1
  33. data/spec/dummy/db/migrate/20130920154445_drop_spud_admin_permissions.tb_core.rb +1 -1
  34. data/spec/dummy/db/migrate/20160310164644_add_requires_password_change_to_spud_users.tb_core.rb +1 -1
  35. data/spec/dummy/db/schema.rb +76 -86
  36. data/spec/factories/spud_banner_sets.rb +9 -0
  37. data/spec/factories/spud_banners.rb +7 -0
  38. data/spec/models/spud_banner_spec.rb +27 -0
  39. data/spec/rails_helper.rb +6 -3
  40. metadata +56 -77
  41. data/lib/spud_banners/liquid_tags.rb +0 -34
  42. data/spec/authlogic_helper.rb +0 -2
  43. data/spec/dummy/db/migrate/20130920154446_create_spud_banners.tb_banners.rb +0 -16
  44. data/spec/dummy/db/migrate/20130920154447_create_spud_banner_sets.tb_banners.rb +0 -13
  45. data/spec/dummy/db/migrate/20130920154448_add_rich_text_to_spud_banners.tb_banners.rb +0 -7
  46. data/spec/dummy/db/migrate/20140120174546_create_tb_liquid_spud_liquid_tags.tb_liquid.rb +0 -13
  47. data/spec/dummy/db/migrate/20160310164427_add_start_and_end_dates_to_spud_banners.tb_banners.rb +0 -7
@@ -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
@@ -3,7 +3,7 @@ module Spud
3
3
  include ActiveSupport::Configurable
4
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"
6
+ self.s3_credentials = './config/s3.yml'
7
7
  self.s3_protocol = 'https'
8
8
  self.storage_path = ':rails_root/public/system/spud_banners/:id/:style/:basename.:extension'
9
9
  self.storage_url = '/system/spud_banners/:id/:style/:basename.:extension'
@@ -1,6 +1,5 @@
1
1
  require 'tb_core'
2
2
  require 'paperclip'
3
- require 'tb_liquid'
4
3
 
5
4
  module Spud
6
5
  module Banners
@@ -8,7 +7,7 @@ module Spud
8
7
  engine_name :tb_banners
9
8
 
10
9
  initializer :admin do
11
- Spud::Core.config.admin_applications += [{
10
+ TbCore.config.admin_applications += [{
12
11
  name: 'Banner Sets',
13
12
  thumbnail: 'admin/banners/banners.png',
14
13
  retina: true,
@@ -17,13 +16,9 @@ module Spud
17
16
  }]
18
17
  end
19
18
 
20
- initializer :liquid do
21
- Liquid::Template.register_tag('spud_banner_set', Spud::Banners::BannerSetTag) if defined?(Liquid::Template)
22
- end
23
-
24
19
  initializer 'tb_banners.assets' do
25
- Spud::Core.append_admin_stylesheets('admin/banners/application')
26
- Spud::Core.append_admin_javascripts('admin/banners/application')
20
+ TbCore.append_admin_stylesheets('admin/banners/application')
21
+ TbCore.append_admin_javascripts('admin/banners/application')
27
22
  Rails.application.config.assets.precompile += ['admin/banners/banners.png']
28
23
  end
29
24
 
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Banners
3
- VERSION = '1.3.beta1'.freeze
3
+ VERSION = '1.3.1'.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
4
  require 'spud_banners/engine' if defined?(Rails)
6
5
  end
7
6
  end
@@ -13,7 +13,7 @@ describe Admin::BannerSetsController, type: 'controller' do
13
13
  describe 'index' do
14
14
  it 'should return an array of banner sets' do
15
15
  5.times do |_x|
16
- banner_set = FactoryGirl.create(:spud_banner_set)
16
+ FactoryBot.create(:spud_banner_set)
17
17
  end
18
18
  get :index
19
19
  expect(assigns(:banner_sets).count).to be > 1
@@ -22,16 +22,16 @@ describe Admin::BannerSetsController, type: 'controller' do
22
22
 
23
23
  describe 'show' do
24
24
  it 'should respond with a banner set' do
25
- banner_set = FactoryGirl.create(:spud_banner_set)
25
+ banner_set = FactoryBot.create(:spud_banner_set)
26
26
  get :show, params: { id: banner_set.id }
27
27
  expect(assigns(:banner_set)).to eq(banner_set)
28
28
  expect(response).to be_success
29
29
  end
30
30
 
31
- it 'should redirect if banner set is not found' do
31
+ it 'should return a 404 if banner set is not found' do
32
32
  get :show, params: { id: -1 }
33
33
  expect(assigns(:banner_set)).to be_blank
34
- expect(response).to redirect_to admin_banner_sets_path
34
+ expect(response.status).to eq(404)
35
35
  end
36
36
  end
37
37
 
@@ -45,7 +45,7 @@ describe Admin::BannerSetsController, type: 'controller' do
45
45
  describe 'create' do
46
46
  it 'should respond with a banner set' do
47
47
  expect do
48
- post :create, params: { spud_banner_set: FactoryGirl.attributes_for(:spud_banner_set) }
48
+ post :create, params: { spud_banner_set: FactoryBot.attributes_for(:spud_banner_set) }
49
49
  end.to change(SpudBannerSet, :count).by(1)
50
50
  expect(response).to be_success
51
51
  end
@@ -60,7 +60,7 @@ describe Admin::BannerSetsController, type: 'controller' do
60
60
 
61
61
  describe 'edit' do
62
62
  it 'should respond with a banner set' do
63
- banner_set = FactoryGirl.create(:spud_banner_set)
63
+ banner_set = FactoryBot.create(:spud_banner_set)
64
64
  get :edit, params: { id: banner_set.id }
65
65
  expect(assigns(:banner_set)).to eq(banner_set)
66
66
  expect(response).to be_success
@@ -69,7 +69,7 @@ describe Admin::BannerSetsController, type: 'controller' do
69
69
 
70
70
  describe 'update' do
71
71
  it 'should update the banner set' do
72
- banner_set = FactoryGirl.create(:spud_banner_set)
72
+ banner_set = FactoryBot.create(:spud_banner_set)
73
73
  new_name = 'Updated Set Name'
74
74
  expect do
75
75
  put :update, params: { id: banner_set.id, spud_banner_set: { name: new_name } }
@@ -78,7 +78,7 @@ describe Admin::BannerSetsController, type: 'controller' do
78
78
  end
79
79
 
80
80
  it 'should respond unsuccessfully if the updated banner set is invalid' do
81
- banner_set = FactoryGirl.create(:spud_banner_set)
81
+ banner_set = FactoryBot.create(:spud_banner_set)
82
82
  expect do
83
83
  put :update, params: { id: banner_set.id, spud_banner_set: { name: '', width: 'lorem', height: 'ipsum' } }
84
84
  end.to_not change(SpudBannerSet, :count)
@@ -88,7 +88,7 @@ describe Admin::BannerSetsController, type: 'controller' do
88
88
 
89
89
  describe 'destroy' do
90
90
  it 'should destroy the banner set and respond successfully' do
91
- banner_set = FactoryGirl.create(:spud_banner_set)
91
+ banner_set = FactoryBot.create(:spud_banner_set)
92
92
  expect do
93
93
  delete :destroy, params: { id: banner_set.id }
94
94
  end.to change(SpudBannerSet, :count).by(-1)
@@ -4,5 +4,4 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = 'dacbd8a483ea9645b13e97018089cbc9da8bf98f99a0be873cdb565d8f64c066974f37cbe7e8b4fedaadd057bce78d1d9326b0768120d2a693de8165df286693'
8
7
  Dummy::Application.config.secret_key_base = 'b43711419c807b9c9efe9365dd79f87ebe31e9f72e1aa6744c1ecac68aace664c0a3a4f791d92bd2fa324fce1d6d09701a54b88453f131b7c460eeb9c530bd72'
@@ -1,5 +1,5 @@
1
1
  # This migration comes from spud_core (originally 20111214161011)
2
- class CreateSpudAdminPermissions < ActiveRecord::Migration
2
+ class CreateSpudAdminPermissions < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  create_table :spud_admin_permissions do |t|
5
5
  t.integer :user_id
@@ -1,5 +1,5 @@
1
1
  # This migration comes from spud_core (originally 20111214161146)
2
- class CreateSpudUsers < ActiveRecord::Migration
2
+ class CreateSpudUsers < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  create_table :spud_users do |t|
5
5
 
@@ -1,5 +1,5 @@
1
1
  # This migration comes from spud_core (originally 20120327124229)
2
- class AddTimeZoneToSpudUser < ActiveRecord::Migration
2
+ class AddTimeZoneToSpudUser < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  add_column :spud_users, :time_zone, :string
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # This migration comes from spud_core (originally 20120328235431)
2
- class AddScopeToSpudAdminPermissions < ActiveRecord::Migration
2
+ class AddScopeToSpudAdminPermissions < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  add_column :spud_admin_permissions, :scope, :string
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # This migration comes from spud_core (originally 20120329174000)
2
- class CreateSpudUserSettings < ActiveRecord::Migration
2
+ class CreateSpudUserSettings < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  create_table :spud_user_settings do |t|
5
5
  t.integer :spud_user_id
@@ -1,5 +1,5 @@
1
1
  # This migration comes from tb_core (originally 20130620143010)
2
- class CreateSpudRoles < ActiveRecord::Migration
2
+ class CreateSpudRoles < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  create_table :spud_roles do |t|
5
5
  t.string :name
@@ -1,5 +1,5 @@
1
1
  # This migration comes from tb_core (originally 20130620143941)
2
- class CreateSpudPermissions < ActiveRecord::Migration
2
+ class CreateSpudPermissions < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  create_table :spud_permissions do |t|
5
5
  t.string :name, null: false
@@ -1,5 +1,5 @@
1
1
  # This migration comes from tb_core (originally 20130620151132)
2
- class CreateSpudRolePermissions < ActiveRecord::Migration
2
+ class CreateSpudRolePermissions < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  create_table :spud_role_permissions do |t|
5
5
  t.integer :spud_role_id, null: false
@@ -1,5 +1,5 @@
1
1
  # This migration comes from tb_core (originally 20130620163144)
2
- class DropSpudAdminPermissions < ActiveRecord::Migration
2
+ class DropSpudAdminPermissions < ActiveRecord::Migration[4.2]
3
3
  def up
4
4
  drop_table :spud_admin_permissions
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # This migration comes from tb_core (originally 20150610143438)
2
- class AddRequiresPasswordChangeToSpudUsers < ActiveRecord::Migration
2
+ class AddRequiresPasswordChangeToSpudUsers < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  add_column :spud_users, :requires_password_change, :boolean, default: false
5
5
  end
@@ -10,105 +10,95 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20_160_310_164_644) do
13
+ ActiveRecord::Schema.define(version: 20160310164644) do
14
14
 
15
- create_table 'spud_banner_sets', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
16
- t.string 'name', null: false
17
- t.integer 'width', null: false
18
- t.integer 'height', null: false
19
- t.boolean 'cropped', default: true
20
- t.datetime 'created_at'
21
- t.datetime 'updated_at'
22
- t.boolean 'has_rich_text', default: false
23
- t.index ['name'], name: 'index_spud_banner_sets_on_name', unique: true, using: :btree
15
+ create_table "spud_banner_sets", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
16
+ t.string "name", null: false
17
+ t.integer "width", null: false
18
+ t.integer "height", null: false
19
+ t.boolean "cropped", default: true
20
+ t.datetime "created_at"
21
+ t.datetime "updated_at"
22
+ t.boolean "has_rich_text", default: false
23
+ t.index ["name"], name: "index_spud_banner_sets_on_name", unique: true
24
24
  end
25
25
 
26
- create_table 'spud_banners', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
27
- t.integer 'spud_banner_set_id', null: false
28
- t.string 'link_to'
29
- t.string 'link_target', default: '_self'
30
- t.string 'title'
31
- t.string 'alt'
32
- t.integer 'sort_order', default: 0
33
- t.string 'banner_file_name'
34
- t.string 'banner_content_type'
35
- t.integer 'banner_file_size'
36
- t.datetime 'banner_updated_at'
37
- t.datetime 'created_at'
38
- t.datetime 'updated_at'
39
- t.text 'rich_text', limit: 65_535
40
- t.date 'start_date'
41
- t.date 'end_date'
42
- t.index ['spud_banner_set_id'], name: 'index_spud_banners_on_spud_banner_set_id', using: :btree
26
+ create_table "spud_banners", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
27
+ t.integer "spud_banner_set_id", null: false
28
+ t.string "link_to"
29
+ t.string "link_target", default: "_self"
30
+ t.string "title"
31
+ t.string "alt"
32
+ t.integer "sort_order", default: 0
33
+ t.string "banner_file_name"
34
+ t.string "banner_content_type"
35
+ t.integer "banner_file_size"
36
+ t.datetime "banner_updated_at"
37
+ t.datetime "created_at"
38
+ t.datetime "updated_at"
39
+ t.text "rich_text"
40
+ t.date "start_date"
41
+ t.date "end_date"
42
+ t.index ["spud_banner_set_id"], name: "index_spud_banners_on_spud_banner_set_id"
43
43
  end
44
44
 
45
- create_table 'spud_liquid_tags', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
46
- t.integer 'attachment_id'
47
- t.string 'attachment_type'
48
- t.string 'tag_name'
49
- t.string 'value'
50
- t.datetime 'created_at'
51
- t.datetime 'updated_at'
52
- t.index ['tag_name', 'value'], name: 'index_spud_liquid_tags_on_tag_name_and_value', using: :btree
45
+ create_table "spud_permissions", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
46
+ t.string "name", null: false
47
+ t.string "tag", null: false
48
+ t.datetime "created_at"
49
+ t.datetime "updated_at"
50
+ t.index ["tag"], name: "index_spud_permissions_on_tag", unique: true
53
51
  end
54
52
 
55
- create_table 'spud_permissions', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
56
- t.string 'name', null: false
57
- t.string 'tag', null: false
58
- t.datetime 'created_at'
59
- t.datetime 'updated_at'
60
- t.index ['tag'], name: 'index_spud_permissions_on_tag', unique: true, using: :btree
53
+ create_table "spud_role_permissions", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
54
+ t.integer "spud_role_id", null: false
55
+ t.string "spud_permission_tag", null: false
56
+ t.datetime "created_at"
57
+ t.datetime "updated_at"
58
+ t.index ["spud_permission_tag"], name: "index_spud_role_permissions_on_spud_permission_tag"
59
+ t.index ["spud_role_id"], name: "index_spud_role_permissions_on_spud_role_id"
61
60
  end
62
61
 
63
- create_table 'spud_role_permissions', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
64
- t.integer 'spud_role_id', null: false
65
- t.string 'spud_permission_tag', null: false
66
- t.datetime 'created_at'
67
- t.datetime 'updated_at'
68
- t.index ['spud_permission_tag'], name: 'index_spud_role_permissions_on_spud_permission_tag', using: :btree
69
- t.index ['spud_role_id'], name: 'index_spud_role_permissions_on_spud_role_id', using: :btree
62
+ create_table "spud_roles", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
63
+ t.string "name"
64
+ t.datetime "created_at"
65
+ t.datetime "updated_at"
70
66
  end
71
67
 
72
- create_table 'spud_roles', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
73
- t.string 'name'
74
- t.datetime 'created_at'
75
- t.datetime 'updated_at'
68
+ create_table "spud_user_settings", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
69
+ t.integer "spud_user_id"
70
+ t.string "key"
71
+ t.string "value"
72
+ t.datetime "created_at"
73
+ t.datetime "updated_at"
76
74
  end
77
75
 
78
- create_table 'spud_user_settings', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
79
- t.integer 'spud_user_id'
80
- t.string 'key'
81
- t.string 'value'
82
- t.datetime 'created_at'
83
- t.datetime 'updated_at'
84
- end
85
-
86
- create_table 'spud_users', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
87
- t.string 'first_name'
88
- t.string 'last_name'
89
- t.boolean 'super_admin'
90
- t.string 'login', null: false
91
- t.string 'email', null: false
92
- t.string 'crypted_password', null: false
93
- t.string 'password_salt', null: false
94
- t.string 'persistence_token', null: false
95
- t.string 'single_access_token', null: false
96
- t.string 'perishable_token', null: false
97
- t.integer 'login_count', default: 0, null: false
98
- t.integer 'failed_login_count', default: 0, null: false
99
- t.datetime 'last_request_at'
100
- t.datetime 'current_login_at'
101
- t.datetime 'last_login_at'
102
- t.string 'current_login_ip'
103
- t.string 'last_login_ip'
104
- t.datetime 'created_at'
105
- t.datetime 'updated_at'
106
- t.string 'time_zone'
107
- t.integer 'spud_role_id'
108
- t.boolean 'requires_password_change', default: false
109
- t.index ['email'], name: 'index_spud_users_on_email', using: :btree
110
- t.index ['login'], name: 'index_spud_users_on_login', using: :btree
111
- t.index ['spud_role_id'], name: 'index_spud_users_on_spud_role_id', using: :btree
76
+ create_table "spud_users", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
77
+ t.string "first_name"
78
+ t.string "last_name"
79
+ t.boolean "super_admin"
80
+ t.string "login", null: false
81
+ t.string "email", null: false
82
+ t.string "crypted_password", null: false
83
+ t.string "password_salt", null: false
84
+ t.string "persistence_token", null: false
85
+ t.string "single_access_token", null: false
86
+ t.string "perishable_token", null: false
87
+ t.integer "login_count", default: 0, null: false
88
+ t.integer "failed_login_count", default: 0, null: false
89
+ t.datetime "last_request_at"
90
+ t.datetime "current_login_at"
91
+ t.datetime "last_login_at"
92
+ t.string "current_login_ip"
93
+ t.string "last_login_ip"
94
+ t.datetime "created_at"
95
+ t.datetime "updated_at"
96
+ t.string "time_zone"
97
+ t.integer "spud_role_id"
98
+ t.boolean "requires_password_change", default: false
99
+ t.index ["email"], name: "index_spud_users_on_email"
100
+ t.index ["login"], name: "index_spud_users_on_login"
101
+ t.index ["spud_role_id"], name: "index_spud_users_on_spud_role_id"
112
102
  end
113
103
 
114
104
  end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :spud_banner_set do
3
+ sequence :name do |i|
4
+ "Test #{i}"
5
+ end
6
+ width 800
7
+ height 200
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :spud_banner do
3
+ banner_file_name 'test.jpg'
4
+ banner_content_type 'image/jpeg'
5
+ banner_file_size 1
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ require 'rails_helper'
2
+
3
+ describe SpudBanner, type: 'model' do
4
+
5
+ let(:set) { create(:spud_banner_set) }
6
+
7
+ describe 'active' do
8
+ it 'returns active banners' do
9
+ banner = create(:spud_banner,
10
+ spud_banner_set_id: set.id,
11
+ start_date: Date.yesterday, end_date: Date.tomorrow)
12
+
13
+ result = SpudBanner.active
14
+ expect(result).to eq([banner])
15
+ end
16
+
17
+ it 'does not return inactive banners' do
18
+ create(:spud_banner,
19
+ spud_banner_set_id: set.id,
20
+ start_date: nil, end_date: Date.yesterday)
21
+
22
+ result = SpudBanner.active
23
+ expect(result).to eq([])
24
+ end
25
+ end
26
+
27
+ end