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.
- checksums.yaml +5 -5
- data/README.markdown +0 -1
- data/Rakefile +1 -1
- data/app/assets/javascripts/admin/banners/banner_sets.js +3 -0
- data/app/assets/javascripts/admin/banners/banners.js +9 -12
- data/app/assets/stylesheets/admin/banners/banners.css.scss +6 -1
- data/app/controllers/admin/banner_sets_controller.rb +9 -13
- data/app/controllers/admin/banners_controller.rb +23 -30
- data/app/helpers/spud_banners_helper.rb +16 -11
- data/app/models/spud_banner.rb +17 -5
- data/app/models/spud_banner_set.rb +3 -4
- data/app/views/admin/banner_sets/show.html.erb +1 -0
- data/app/views/admin/banners/_banner.html.erb +4 -1
- data/app/views/admin/banners/_form.html.erb +2 -2
- 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 +1 -1
- data/lib/spud_banners/engine.rb +3 -8
- data/lib/spud_banners/version.rb +1 -1
- data/lib/tb_banners.rb +0 -1
- data/spec/controllers/admin/banner_sets_controller_spec.rb +9 -9
- 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 +1 -1
- data/spec/dummy/db/migrate/20121127192248_add_time_zone_to_spud_user.spud_core.rb +1 -1
- data/spec/dummy/db/migrate/20121127192249_add_scope_to_spud_admin_permissions.spud_core.rb +1 -1
- 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 +1 -1
- data/spec/dummy/db/migrate/20130920154444_create_spud_role_permissions.tb_core.rb +1 -1
- 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 +1 -1
- data/spec/dummy/db/schema.rb +76 -86
- 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 +6 -3
- metadata +56 -77
- data/lib/spud_banners/liquid_tags.rb +0 -34
- data/spec/authlogic_helper.rb +0 -2
- 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/dummy/db/migrate/20160310164427_add_start_and_end_dates_to_spud_banners.tb_banners.rb +0 -7
@@ -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 =
|
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'
|
data/lib/spud_banners/engine.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
26
|
-
|
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
|
|
data/lib/spud_banners/version.rb
CHANGED
data/lib/tb_banners.rb
CHANGED
@@ -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
|
-
|
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 =
|
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
|
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
|
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:
|
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 =
|
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 =
|
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 =
|
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 =
|
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 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 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
|
data/spec/dummy/db/migrate/20160310164644_add_requires_password_change_to_spud_users.tb_core.rb
CHANGED
@@ -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
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -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:
|
13
|
+
ActiveRecord::Schema.define(version: 20160310164644) do
|
14
14
|
|
15
|
-
create_table
|
16
|
-
t.string
|
17
|
-
t.integer
|
18
|
-
t.integer
|
19
|
-
t.boolean
|
20
|
-
t.datetime
|
21
|
-
t.datetime
|
22
|
-
t.boolean
|
23
|
-
t.index [
|
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
|
27
|
-
t.integer
|
28
|
-
t.string
|
29
|
-
t.string
|
30
|
-
t.string
|
31
|
-
t.string
|
32
|
-
t.integer
|
33
|
-
t.string
|
34
|
-
t.string
|
35
|
-
t.integer
|
36
|
-
t.datetime
|
37
|
-
t.datetime
|
38
|
-
t.datetime
|
39
|
-
t.text
|
40
|
-
t.date
|
41
|
-
t.date
|
42
|
-
t.index [
|
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
|
46
|
-
t.
|
47
|
-
t.string
|
48
|
-
t.
|
49
|
-
t.
|
50
|
-
t.
|
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
|
56
|
-
t.
|
57
|
-
t.string
|
58
|
-
t.datetime
|
59
|
-
t.datetime
|
60
|
-
t.index [
|
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
|
64
|
-
t.
|
65
|
-
t.
|
66
|
-
t.datetime
|
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
|
73
|
-
t.
|
74
|
-
t.
|
75
|
-
t.
|
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
|
79
|
-
t.
|
80
|
-
t.string
|
81
|
-
t.
|
82
|
-
t.
|
83
|
-
t.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
t.string
|
88
|
-
t.string
|
89
|
-
t.
|
90
|
-
t.
|
91
|
-
t.
|
92
|
-
t.
|
93
|
-
t.
|
94
|
-
t.string
|
95
|
-
t.string
|
96
|
-
t.
|
97
|
-
t.
|
98
|
-
t.
|
99
|
-
t.
|
100
|
-
t.
|
101
|
-
t.
|
102
|
-
t.
|
103
|
-
t.
|
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,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
|