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
data/spec/dummy/config.ru
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../boot', __FILE__)
|
|
3
3
|
require 'rails/all'
|
4
4
|
|
5
5
|
Bundler.require
|
6
|
-
require
|
6
|
+
require 'tb_banners'
|
7
7
|
|
8
8
|
module Dummy
|
9
9
|
class Application < Rails::Application
|
@@ -31,7 +31,7 @@ module Dummy
|
|
31
31
|
config.i18n.enforce_available_locales = true
|
32
32
|
|
33
33
|
# Configure the default encoding used in templates for Ruby 1.9.
|
34
|
-
config.encoding =
|
34
|
+
config.encoding = 'utf-8'
|
35
35
|
|
36
36
|
# Configure sensitive parameters which will be filtered from the log file.
|
37
37
|
config.filter_parameters += [:password]
|
@@ -51,4 +51,3 @@ module Dummy
|
|
51
51
|
config.assets.version = '1.0'
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -9,7 +9,7 @@ Dummy::Application.configure do
|
|
9
9
|
config.action_controller.perform_caching = true
|
10
10
|
|
11
11
|
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
-
config.
|
12
|
+
config.public_file_server.enabled = false
|
13
13
|
|
14
14
|
# Compress JavaScripts and CSS
|
15
15
|
config.assets.compress = true
|
@@ -8,8 +8,8 @@ Dummy::Application.configure do
|
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
10
|
# Configure static asset server for tests with Cache-Control for performance
|
11
|
-
config.
|
12
|
-
config.
|
11
|
+
config.public_file_server.enabled = true
|
12
|
+
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
|
13
13
|
|
14
14
|
# Deprecated
|
15
15
|
# Log error messages when you accidentally call methods on nil
|
@@ -20,7 +20,6 @@ Dummy::Application.configure do
|
|
20
20
|
# preloads Rails for running tests, you may have to set it to true.
|
21
21
|
config.eager_load = false
|
22
22
|
|
23
|
-
|
24
23
|
# Show full error reports and disable caching
|
25
24
|
config.consider_all_requests_local = true
|
26
25
|
config.action_controller.perform_caching = false
|
@@ -29,7 +28,7 @@ Dummy::Application.configure do
|
|
29
28
|
config.action_dispatch.show_exceptions = false
|
30
29
|
|
31
30
|
# Disable request forgery protection in test environment
|
32
|
-
config.action_controller.allow_forgery_protection
|
31
|
+
config.action_controller.allow_forgery_protection = false
|
33
32
|
|
34
33
|
# Tell Action Mailer not to deliver emails to the real world.
|
35
34
|
# The :test delivery method accumulates sent emails in the
|
@@ -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,22 +1,22 @@
|
|
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
|
+
|
6
6
|
t.string :first_name
|
7
7
|
t.string :last_name
|
8
8
|
t.boolean :super_admin
|
9
|
-
t.string :login, :
|
10
|
-
t.string :email, :
|
11
|
-
t.string :crypted_password, :
|
12
|
-
t.string :password_salt, :
|
13
|
-
t.string :persistence_token, :
|
14
|
-
t.string :single_access_token, :
|
15
|
-
t.string :perishable_token, :
|
9
|
+
t.string :login, null: false # optional, you can use email instead, or both
|
10
|
+
t.string :email, null: false # optional, you can use login instead, or both
|
11
|
+
t.string :crypted_password, null: false # optional, see below
|
12
|
+
t.string :password_salt, null: false # optional, but highly recommended
|
13
|
+
t.string :persistence_token, null: false # required
|
14
|
+
t.string :single_access_token, null: false # optional, see Authlogic::Session::Params
|
15
|
+
t.string :perishable_token, null: false # optional, see Authlogic::Session::Perishability
|
16
16
|
|
17
17
|
# Magic columns, just like ActiveRecord's created_at and updated_at. These are automatically maintained by Authlogic if they are present.
|
18
|
-
t.integer :login_count, :
|
19
|
-
t.integer :failed_login_count, :
|
18
|
+
t.integer :login_count, null: false, default: 0 # optional, see Authlogic::Session::MagicColumns
|
19
|
+
t.integer :failed_login_count, null: false, default: 0 # optional, see Authlogic::Session::MagicColumns
|
20
20
|
t.datetime :last_request_at # optional, see Authlogic::Session::MagicColumns
|
21
21
|
t.datetime :current_login_at # optional, see Authlogic::Session::MagicColumns
|
22
22
|
t.datetime :last_login_at # optional, see Authlogic::Session::MagicColumns
|
@@ -24,7 +24,7 @@ class CreateSpudUsers < ActiveRecord::Migration
|
|
24
24
|
t.string :last_login_ip # optional, see Authlogic::Session::MagicColumns
|
25
25
|
t.timestamps
|
26
26
|
end
|
27
|
-
add_index :spud_users
|
28
|
-
add_index :spud_users
|
27
|
+
add_index :spud_users, :login
|
28
|
+
add_index :spud_users, :email
|
29
29
|
end
|
30
30
|
end
|
@@ -1,7 +1,6 @@
|
|
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
|
-
|
6
5
|
end
|
7
6
|
end
|
@@ -1,11 +1,11 @@
|
|
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
|
-
t.string :name, :
|
6
|
-
t.string :tag, :
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :tag, null: false
|
7
7
|
t.timestamps
|
8
8
|
end
|
9
|
-
add_index :spud_permissions, :tag, :
|
9
|
+
add_index :spud_permissions, :tag, unique: true
|
10
10
|
end
|
11
11
|
end
|
@@ -1,9 +1,9 @@
|
|
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
|
-
t.integer :spud_role_id, :
|
6
|
-
t.string :spud_permission_tag, :
|
5
|
+
t.integer :spud_role_id, null: false
|
6
|
+
t.string :spud_permission_tag, null: false
|
7
7
|
t.timestamps
|
8
8
|
end
|
9
9
|
add_index :spud_role_permissions, :spud_role_id
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -11,108 +10,95 @@
|
|
11
10
|
#
|
12
11
|
# It's strongly recommended that you check this file into your version control system.
|
13
12
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 20160310164644) do
|
15
14
|
|
16
|
-
create_table "spud_banner_sets", force:
|
17
|
-
t.string
|
18
|
-
t.integer
|
19
|
-
t.integer
|
20
|
-
t.boolean
|
21
|
-
t.datetime "created_at"
|
22
|
-
t.datetime "updated_at"
|
23
|
-
t.boolean
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
t.
|
30
|
-
t.string
|
31
|
-
t.string
|
32
|
-
t.
|
33
|
-
t.string
|
34
|
-
t.
|
35
|
-
t.
|
36
|
-
t.string "banner_content_type"
|
37
|
-
t.integer "banner_file_size"
|
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"
|
38
36
|
t.datetime "banner_updated_at"
|
39
|
-
t.datetime "created_at", null: false
|
40
|
-
t.datetime "updated_at", null: false
|
41
|
-
t.text "rich_text"
|
42
|
-
end
|
43
|
-
|
44
|
-
add_index "spud_banners", ["spud_banner_set_id"], name: "index_spud_banners_on_spud_banner_set_id", using: :btree
|
45
|
-
|
46
|
-
create_table "spud_liquid_tags", force: true do |t|
|
47
|
-
t.integer "attachment_id"
|
48
|
-
t.string "attachment_type"
|
49
|
-
t.string "tag_name"
|
50
|
-
t.string "value"
|
51
37
|
t.datetime "created_at"
|
52
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"
|
53
43
|
end
|
54
44
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
t.
|
59
|
-
t.
|
60
|
-
t.
|
61
|
-
t.datetime "updated_at", null: false
|
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
|
62
51
|
end
|
63
52
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
t.
|
68
|
-
t.
|
69
|
-
t.
|
70
|
-
t.
|
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"
|
71
60
|
end
|
72
61
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
t.string "name"
|
78
|
-
t.datetime "created_at", null: false
|
79
|
-
t.datetime "updated_at", null: false
|
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"
|
80
66
|
end
|
81
67
|
|
82
|
-
create_table "spud_user_settings", force:
|
83
|
-
t.integer
|
84
|
-
t.string
|
85
|
-
t.string
|
86
|
-
t.datetime "created_at"
|
87
|
-
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"
|
88
74
|
end
|
89
75
|
|
90
|
-
create_table "spud_users", force:
|
91
|
-
t.string
|
92
|
-
t.string
|
93
|
-
t.boolean
|
94
|
-
t.string
|
95
|
-
t.string
|
96
|
-
t.string
|
97
|
-
t.string
|
98
|
-
t.string
|
99
|
-
t.string
|
100
|
-
t.string
|
101
|
-
t.integer
|
102
|
-
t.integer
|
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
|
103
89
|
t.datetime "last_request_at"
|
104
90
|
t.datetime "current_login_at"
|
105
91
|
t.datetime "last_login_at"
|
106
|
-
t.string
|
107
|
-
t.string
|
108
|
-
t.datetime "created_at"
|
109
|
-
t.datetime "updated_at"
|
110
|
-
t.string
|
111
|
-
t.integer
|
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
|
-
add_index "spud_users", ["email"], name: "index_spud_users_on_email", using: :btree
|
115
|
-
add_index "spud_users", ["login"], name: "index_spud_users_on_login", using: :btree
|
116
|
-
add_index "spud_users", ["spud_role_id"], name: "index_spud_users_on_spud_role_id", using: :btree
|
117
|
-
|
118
104
|
end
|
data/spec/dummy/script/rails
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
3
|
|
4
|
-
APP_PATH = File.expand_path('../../config/application',
|
5
|
-
require File.expand_path('../../config/boot',
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
6
|
require 'rails/commands'
|
@@ -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
|