tb_media 1.2.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Rakefile +2 -2
- data/Readme.markdown +3 -19
- data/app/assets/javascripts/admin/media/application.js +2 -2
- data/app/assets/javascripts/admin/media/picker.js +8 -5
- data/app/assets/javascripts/admin/media/plugin.js.erb +86 -81
- data/app/assets/stylesheets/admin/media/application.css.scss +1 -12
- data/app/controllers/admin/media_controller.rb +54 -61
- data/app/controllers/admin/media_picker_controller.rb +8 -16
- data/app/models/spud_media.rb +63 -110
- data/app/views/admin/media/index.html.erb +4 -12
- data/app/views/admin/media/new.html.erb +0 -1
- data/app/views/admin/media_picker/_media.html.erb +2 -7
- data/app/views/admin/media_picker/index.html.erb +1 -2
- data/config/locales/en.yml +0 -1
- data/config/routes.rb +5 -8
- data/db/migrate/20120101194256_create_spud_media.rb +2 -2
- data/db/migrate/20120501203325_add_protected_to_spud_media.rb +1 -2
- data/db/migrate/20120508132153_add_cropping_to_spud_media.rb +1 -1
- data/lib/spud_media/configuration.rb +3 -4
- data/lib/spud_media/content_types.rb +2 -2
- data/lib/spud_media/engine.rb +21 -13
- data/lib/spud_media/version.rb +3 -3
- data/lib/tasks/spud_media_tasks.rake +4 -6
- data/spec/controllers/admin/media_controller_spec.rb +23 -24
- 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/development.rb +0 -7
- data/spec/dummy/config/environments/test.rb +3 -5
- data/spec/dummy/config/routes.rb +2 -2
- data/spec/dummy/db/migrate/20130904141442_create_spud_users.tb_core.rb +12 -12
- data/spec/dummy/db/migrate/20130904141443_add_time_zone_to_spud_user.tb_core.rb +0 -1
- data/spec/dummy/db/migrate/20130904141444_add_scope_to_spud_admin_permissions.tb_core.rb +0 -1
- data/spec/dummy/db/migrate/20130904141446_create_spud_media.tb_media.rb +1 -1
- data/spec/dummy/db/migrate/20130904141447_add_protected_to_spud_media.tb_media.rb +1 -1
- data/spec/dummy/db/migrate/20130904141448_add_cropping_to_spud_media.tb_media.rb +3 -3
- data/spec/dummy/db/migrate/20151012194531_create_spud_permissions.tb_core.rb +3 -3
- data/spec/dummy/db/migrate/20151012194532_create_spud_role_permissions.tb_core.rb +2 -2
- data/spec/dummy/db/migrate/20151012194534_add_requires_password_change_to_spud_users.tb_core.rb +1 -1
- data/spec/dummy/db/schema.rb +63 -67
- data/spec/dummy/public/system/spud_media/1/cropped/test_img1.png +0 -0
- data/spec/dummy/public/system/spud_media/1/small/test_img1.png +0 -0
- data/spec/dummy/public/system/spud_media/2/cropped/test_img1.png +0 -0
- data/spec/dummy/public/system/spud_media/2/small/test_img1.png +0 -0
- data/spec/dummy/public/system/spud_media/3/cropped/test_img1.png +0 -0
- data/spec/dummy/public/system/spud_media/3/small/test_img1.png +0 -0
- data/spec/dummy/public/system/spud_media/4/cropped/test_img1.png +0 -0
- data/spec/dummy/public/system/spud_media/4/small/test_img1.png +0 -0
- data/spec/dummy/public/system/spud_media/5/cropped/test_img1.png +0 -0
- data/spec/dummy/public/system/spud_media/5/small/test_img1.png +0 -0
- data/spec/dummy/script/rails +2 -2
- data/spec/javascripts/support/jasmine_helper.rb +6 -7
- data/spec/models/spud_media_spec.rb +2 -2
- data/spec/rails_helper.rb +14 -7
- data/spec/spec_helper.rb +42 -44
- metadata +103 -104
- data/app/controllers/protected_media_controller.rb +0 -24
- data/app/helpers/protected_media_helper.rb +0 -3
- data/spec/dummy/public/system/spud_media/1/cropped/test_img1.jpg +0 -0
- data/spec/dummy/public/system/spud_media/2/cropped/test_img1.jpg +0 -0
- data/spec/dummy/public/system/spud_media/3/cropped/test_img1.jpg +0 -0
- data/spec/dummy/public/system/spud_media/4/cropped/test_img1.jpg +0 -0
- data/spec/dummy/public/system/spud_media/5/cropped/test_img1.jpg +0 -0
- data/spec/support/authlogic_helper.rb +0 -2
data/lib/spud_media/version.rb
CHANGED
@@ -5,11 +5,9 @@
|
|
5
5
|
|
6
6
|
namespace :spud_media do
|
7
7
|
|
8
|
-
desc
|
9
|
-
task :
|
10
|
-
SpudMedia.find_each
|
11
|
-
m.validate_permissions
|
12
|
-
end
|
8
|
+
desc 'Validate that all media files have the proper permission settings'
|
9
|
+
task validate_permissions: :environment do
|
10
|
+
SpudMedia.find_each(&:validate_permissions)
|
13
11
|
end
|
14
12
|
|
15
|
-
end
|
13
|
+
end
|
@@ -1,44 +1,43 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe Admin::MediaController, :
|
3
|
+
describe Admin::MediaController, 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
13
|
describe 'index' do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
it 'index page should return all media in descending order by create_at' do
|
15
|
+
@media1 = FactoryBot.create(:spud_media, created_at: 1.hour.ago)
|
16
|
+
@media2 = FactoryBot.create(:spud_media, created_at: 2.hours.ago)
|
17
|
+
@media3 = FactoryBot.create(:spud_media, created_at: 3.hours.ago)
|
18
|
+
get :index
|
19
|
+
@medias = assigns(:media)
|
20
|
+
expect(@medias.count).to eq(3)
|
21
|
+
expect(@medias[0].id).to eq(@media1.id)
|
22
|
+
expect(@medias[1].id).to eq(@media2.id)
|
23
|
+
expect(@medias[2].id).to eq(@media3.id)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe 'new' do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
it 'should return a new media object' do
|
29
|
+
get :new
|
30
|
+
@media = assigns(:media)
|
31
|
+
expect(@media).to_not be_blank
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe 'create' do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
36
|
+
it "should create a new media and returned the saved object's edit page" do
|
37
|
+
expect do
|
38
|
+
post :create, params: { spud_media: FactoryBot.attributes_for(:spud_media) }
|
39
|
+
end.to change(SpudMedia, :count).by(1)
|
40
|
+
end
|
42
41
|
end
|
43
42
|
|
44
|
-
end
|
43
|
+
end
|
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_media'
|
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]
|
@@ -54,4 +54,3 @@ module Dummy
|
|
54
54
|
config.assets.version = '1.0'
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -22,13 +22,6 @@ Dummy::Application.configure do
|
|
22
22
|
# Only use best-standards-support built into browsers
|
23
23
|
config.action_dispatch.best_standards_support = :builtin
|
24
24
|
|
25
|
-
# Raise exception on mass assignment protection for Active Record models
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
-
|
28
|
-
# Log the query plan for queries taking more than this (works
|
29
|
-
# with SQLite, MySQL, and PostgreSQL)
|
30
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
-
|
32
25
|
# Do not compress assets
|
33
26
|
config.assets.compress = false
|
34
27
|
|
@@ -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.serve_static_assets = true
|
12
|
+
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
|
13
13
|
|
14
14
|
# Do not eager load code on boot. This avoids loading your whole application
|
15
15
|
# just for the purpose of running a single test. If you are using a tool that
|
@@ -24,7 +24,7 @@ Dummy::Application.configure do
|
|
24
24
|
config.action_dispatch.show_exceptions = false
|
25
25
|
|
26
26
|
# Disable request forgery protection in test environment
|
27
|
-
config.action_controller.allow_forgery_protection
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
28
28
|
|
29
29
|
# Tell Action Mailer not to deliver emails to the real world.
|
30
30
|
# The :test delivery method accumulates sent emails in the
|
@@ -33,6 +33,4 @@ Dummy::Application.configure do
|
|
33
33
|
|
34
34
|
# Print deprecation notices to the stderr
|
35
35
|
config.active_support.deprecation = :stderr
|
36
|
-
|
37
|
-
config.active_record.raise_in_transactional_callbacks = true
|
38
36
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
class CreateSpudUsers < ActiveRecord::Migration
|
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,7 @@
|
|
1
1
|
# This migration comes from tb_media (originally 20120501203325)
|
2
2
|
class AddProtectedToSpudMedia < ActiveRecord::Migration
|
3
3
|
def change
|
4
|
-
add_column :spud_media, :is_protected, :boolean, :
|
4
|
+
add_column :spud_media, :is_protected, :boolean, default: false
|
5
5
|
add_column :spud_media, :attachment_updated_at, :datetime
|
6
6
|
end
|
7
7
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# This migration comes from tb_media (originally 20120508132153)
|
2
2
|
class AddCroppingToSpudMedia < ActiveRecord::Migration
|
3
3
|
def change
|
4
|
-
add_column :spud_media, :crop_x, :int, :
|
5
|
-
add_column :spud_media, :crop_y, :int, :
|
4
|
+
add_column :spud_media, :crop_x, :int, default: 0
|
5
|
+
add_column :spud_media, :crop_y, :int, default: 0
|
6
6
|
add_column :spud_media, :crop_w, :int
|
7
7
|
add_column :spud_media, :crop_h, :int
|
8
|
-
add_column :spud_media, :crop_s, :int, :
|
8
|
+
add_column :spud_media, :crop_s, :int, default: 100
|
9
9
|
end
|
10
10
|
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
class CreateSpudPermissions < ActiveRecord::Migration
|
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
|
@@ -2,8 +2,8 @@
|
|
2
2
|
class CreateSpudRolePermissions < ActiveRecord::Migration
|
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/migrate/20151012194534_add_requires_password_change_to_spud_users.tb_core.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This migration comes from tb_core (originally 20150610143438)
|
2
2
|
class AddRequiresPasswordChangeToSpudUsers < ActiveRecord::Migration
|
3
3
|
def change
|
4
|
-
add_column :spud_users, :requires_password_change, :boolean, :
|
4
|
+
add_column :spud_users, :requires_password_change, :boolean, default: false
|
5
5
|
end
|
6
6
|
end
|
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,83 +10,80 @@
|
|
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: 20_151_012_194_534) do
|
15
14
|
|
16
|
-
create_table
|
17
|
-
t.string
|
18
|
-
t.integer
|
19
|
-
t.string
|
20
|
-
t.datetime
|
21
|
-
t.datetime
|
22
|
-
t.boolean
|
23
|
-
t.datetime
|
24
|
-
t.integer
|
25
|
-
t.integer
|
26
|
-
t.integer
|
27
|
-
t.integer
|
28
|
-
t.integer
|
15
|
+
create_table 'spud_media', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
16
|
+
t.string 'attachment_content_type'
|
17
|
+
t.integer 'attachment_file_size'
|
18
|
+
t.string 'attachment_file_name'
|
19
|
+
t.datetime 'created_at'
|
20
|
+
t.datetime 'updated_at'
|
21
|
+
t.boolean 'is_protected', default: false
|
22
|
+
t.datetime 'attachment_updated_at'
|
23
|
+
t.integer 'crop_x', default: 0
|
24
|
+
t.integer 'crop_y', default: 0
|
25
|
+
t.integer 'crop_w'
|
26
|
+
t.integer 'crop_h'
|
27
|
+
t.integer 'crop_s', default: 100
|
29
28
|
end
|
30
29
|
|
31
|
-
create_table
|
32
|
-
t.string
|
33
|
-
t.string
|
34
|
-
t.datetime
|
35
|
-
t.datetime
|
30
|
+
create_table 'spud_permissions', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
31
|
+
t.string 'name', null: false
|
32
|
+
t.string 'tag', null: false
|
33
|
+
t.datetime 'created_at'
|
34
|
+
t.datetime 'updated_at'
|
35
|
+
t.index ['tag'], name: 'index_spud_permissions_on_tag', unique: true, using: :btree
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
t.
|
42
|
-
t.
|
43
|
-
t.
|
44
|
-
t.
|
38
|
+
create_table 'spud_role_permissions', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
39
|
+
t.integer 'spud_role_id', null: false
|
40
|
+
t.string 'spud_permission_tag', null: false
|
41
|
+
t.datetime 'created_at'
|
42
|
+
t.datetime 'updated_at'
|
43
|
+
t.index ['spud_permission_tag'], name: 'index_spud_role_permissions_on_spud_permission_tag', using: :btree
|
44
|
+
t.index ['spud_role_id'], name: 'index_spud_role_permissions_on_spud_role_id', using: :btree
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
t.string "name", limit: 255
|
52
|
-
t.datetime "created_at"
|
53
|
-
t.datetime "updated_at"
|
47
|
+
create_table 'spud_roles', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
48
|
+
t.string 'name'
|
49
|
+
t.datetime 'created_at'
|
50
|
+
t.datetime 'updated_at'
|
54
51
|
end
|
55
52
|
|
56
|
-
create_table
|
57
|
-
t.integer
|
58
|
-
t.string
|
59
|
-
t.string
|
60
|
-
t.datetime
|
61
|
-
t.datetime
|
53
|
+
create_table 'spud_user_settings', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
54
|
+
t.integer 'spud_user_id'
|
55
|
+
t.string 'key'
|
56
|
+
t.string 'value'
|
57
|
+
t.datetime 'created_at'
|
58
|
+
t.datetime 'updated_at'
|
62
59
|
end
|
63
60
|
|
64
|
-
create_table
|
65
|
-
t.string
|
66
|
-
t.string
|
67
|
-
t.boolean
|
68
|
-
t.string
|
69
|
-
t.string
|
70
|
-
t.string
|
71
|
-
t.string
|
72
|
-
t.string
|
73
|
-
t.string
|
74
|
-
t.string
|
75
|
-
t.integer
|
76
|
-
t.integer
|
77
|
-
t.datetime
|
78
|
-
t.datetime
|
79
|
-
t.datetime
|
80
|
-
t.string
|
81
|
-
t.string
|
82
|
-
t.datetime
|
83
|
-
t.datetime
|
84
|
-
t.string
|
85
|
-
t.integer
|
86
|
-
t.boolean
|
61
|
+
create_table 'spud_users', force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
62
|
+
t.string 'first_name'
|
63
|
+
t.string 'last_name'
|
64
|
+
t.boolean 'super_admin'
|
65
|
+
t.string 'login', null: false
|
66
|
+
t.string 'email', null: false
|
67
|
+
t.string 'crypted_password', null: false
|
68
|
+
t.string 'password_salt', null: false
|
69
|
+
t.string 'persistence_token', null: false
|
70
|
+
t.string 'single_access_token', null: false
|
71
|
+
t.string 'perishable_token', null: false
|
72
|
+
t.integer 'login_count', default: 0, null: false
|
73
|
+
t.integer 'failed_login_count', default: 0, null: false
|
74
|
+
t.datetime 'last_request_at'
|
75
|
+
t.datetime 'current_login_at'
|
76
|
+
t.datetime 'last_login_at'
|
77
|
+
t.string 'current_login_ip'
|
78
|
+
t.string 'last_login_ip'
|
79
|
+
t.datetime 'created_at'
|
80
|
+
t.datetime 'updated_at'
|
81
|
+
t.string 'time_zone'
|
82
|
+
t.integer 'spud_role_id'
|
83
|
+
t.boolean 'requires_password_change', default: false
|
84
|
+
t.index ['email'], name: 'index_spud_users_on_email', using: :btree
|
85
|
+
t.index ['login'], name: 'index_spud_users_on_login', using: :btree
|
86
|
+
t.index ['spud_role_id'], name: 'index_spud_users_on_spud_role_id', using: :btree
|
87
87
|
end
|
88
88
|
|
89
|
-
add_index "spud_users", ["email"], name: "index_spud_users_on_email", using: :btree
|
90
|
-
add_index "spud_users", ["login"], name: "index_spud_users_on_login", using: :btree
|
91
|
-
add_index "spud_users", ["spud_role_id"], name: "index_spud_users_on_spud_role_id", using: :btree
|
92
|
-
|
93
89
|
end
|