tb_core 1.3.10 → 1.4.beta1
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 +4 -4
- data/Rakefile +5 -20
- data/app/controllers/admin/application_controller.rb +2 -2
- data/app/controllers/admin/dashboard_controller.rb +4 -4
- data/app/controllers/admin/password_resets_controller.rb +9 -9
- data/app/controllers/admin/roles_controller.rb +8 -8
- data/app/controllers/admin/settings_controller.rb +11 -9
- data/app/controllers/admin/setup_controller.rb +5 -5
- data/app/controllers/admin/user_sessions_controller.rb +2 -2
- data/app/controllers/admin/users_controller.rb +13 -13
- data/app/controllers/password_resets_controller.rb +7 -7
- data/app/controllers/spud/admin/application_controller.rb +5 -1
- data/app/controllers/spud/application_controller.rb +15 -11
- data/app/controllers/user_sessions_controller.rb +11 -5
- data/app/helpers/admin/application_helper.rb +20 -14
- data/app/helpers/tb_core/application_helper.rb +20 -16
- data/app/mailers/tb_core_mailer.rb +9 -3
- data/app/models/spud/spud_user_model.rb +7 -13
- data/app/models/spud_role.rb +4 -4
- data/app/models/spud_user_setting.rb +2 -2
- data/config/routes.rb +3 -3
- data/lib/generators/spud/controller_spec_generator.rb +6 -3
- data/lib/generators/spud/module_generator.rb +56 -41
- data/lib/generators/spud/setup_generator.rb +26 -22
- data/lib/generators/spud/templates/admin_controller.rb.erb +9 -13
- data/lib/generators/spud/templates/controller.rb.erb +4 -6
- data/lib/generators/spud/templates/controller_spec.rb.erb +16 -21
- data/lib/generators/spud/templates/views/layouts/application.html.erb +1 -1
- data/lib/spud_core/catch_all_route.rb +1 -1
- data/lib/spud_core/configuration.rb +7 -3
- data/lib/spud_core/engine.rb +5 -18
- data/lib/spud_core/errors.rb +3 -4
- data/lib/spud_core/test_files.rb +3 -3
- data/lib/spud_core/version.rb +1 -1
- data/lib/tb_core/belongs_to_app.rb +6 -3
- data/lib/tb_core/form_builder.rb +40 -33
- data/lib/tb_core/responder.rb +2 -2
- data/lib/tb_core/test_helper.rb +2 -2
- data/spec/controllers/admin/application_controller_spec.rb +14 -14
- data/spec/controllers/admin/dashboard_controller_spec.rb +26 -23
- data/spec/controllers/admin/password_reset_controller_spec.rb +29 -30
- data/spec/controllers/admin/settings_controller_spec.rb +13 -13
- data/spec/controllers/admin/setup_controller_spec.rb +12 -12
- data/spec/controllers/admin/user_sessions_controller_spec.rb +3 -3
- data/spec/controllers/admin/users_controller_spec.rb +68 -65
- data/spec/controllers/spud/application_controller_spec.rb +1 -1
- data/spec/dummy/config/application.rb +6 -7
- data/spec/dummy/config/database.yml +7 -16
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/config/environments/test.rb +5 -2
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/db/schema.rb +53 -54
- data/spec/factories/spud_user_factories.rb +2 -2
- data/spec/helpers/spud/admin/application_helper_spec.rb +4 -4
- data/spec/lib/spud_core/configuration_spec.rb +2 -2
- data/spec/lib/tb_core/belongs_to_app_spec.rb +4 -4
- data/spec/models/spud_role_spec.rb +9 -9
- data/spec/models/spud_user_spec.rb +19 -32
- data/spec/rails_helper.rb +5 -6
- metadata +67 -77
- data/lib/responds_to_parent.rb +0 -69
- data/lib/tb_core/mysql2_extensions.rb +0 -45
- data/spec/dummy/db/migrate/20141214200804_create_spud_admin_permissions.tb_core.rb +0 -12
- data/spec/dummy/db/migrate/20141214200805_create_spud_users.tb_core.rb +0 -30
- data/spec/dummy/db/migrate/20141214200806_add_time_zone_to_spud_user.tb_core.rb +0 -7
- data/spec/dummy/db/migrate/20141214200807_add_scope_to_spud_admin_permissions.tb_core.rb +0 -7
- data/spec/dummy/db/migrate/20141214200808_create_spud_user_settings.tb_core.rb +0 -12
- data/spec/dummy/db/migrate/20141214200809_create_spud_roles.tb_core.rb +0 -11
- data/spec/dummy/db/migrate/20141214200810_create_spud_permissions.tb_core.rb +0 -11
- data/spec/dummy/db/migrate/20141214200811_create_spud_role_permissions.tb_core.rb +0 -12
- data/spec/dummy/db/migrate/20141214200812_drop_spud_admin_permissions.tb_core.rb +0 -16
- data/spec/dummy/db/migrate/20150610180845_add_requires_password_change_to_spud_users.tb_core.rb +0 -6
- data/spec/lib/tb_core/mysql2_extensions_spec.rb +0 -59
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,68 +10,68 @@
|
|
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: 20150610143438) do
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
t.string "tag", limit: 255, null: false
|
19
|
-
t.datetime "created_at"
|
20
|
-
t.datetime "updated_at"
|
21
|
-
end
|
22
|
-
|
23
|
-
add_index "spud_permissions", ["tag"], name: "index_spud_permissions_on_tag", unique: true, using: :btree
|
15
|
+
# These are extensions that must be enabled in order to support this database
|
16
|
+
enable_extension 'plpgsql'
|
24
17
|
|
25
|
-
create_table
|
26
|
-
t.
|
27
|
-
t.string
|
28
|
-
t.datetime
|
29
|
-
t.datetime
|
18
|
+
create_table 'spud_permissions', force: :cascade do |t|
|
19
|
+
t.string 'name', null: false
|
20
|
+
t.string 'tag', null: false
|
21
|
+
t.datetime 'created_at'
|
22
|
+
t.datetime 'updated_at'
|
23
|
+
t.index ['tag'], name: 'index_spud_permissions_on_tag', unique: true, using: :btree
|
30
24
|
end
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
t.
|
37
|
-
t.
|
38
|
-
t.
|
26
|
+
create_table 'spud_role_permissions', force: :cascade do |t|
|
27
|
+
t.integer 'spud_role_id', null: false
|
28
|
+
t.string 'spud_permission_tag', null: false
|
29
|
+
t.datetime 'created_at'
|
30
|
+
t.datetime 'updated_at'
|
31
|
+
t.index ['spud_permission_tag'], name: 'index_spud_role_permissions_on_spud_permission_tag', using: :btree
|
32
|
+
t.index ['spud_role_id'], name: 'index_spud_role_permissions_on_spud_role_id', using: :btree
|
39
33
|
end
|
40
34
|
|
41
|
-
create_table
|
42
|
-
t.
|
43
|
-
t.
|
44
|
-
t.
|
45
|
-
t.datetime "created_at"
|
46
|
-
t.datetime "updated_at"
|
35
|
+
create_table 'spud_roles', force: :cascade do |t|
|
36
|
+
t.string 'name'
|
37
|
+
t.datetime 'created_at'
|
38
|
+
t.datetime 'updated_at'
|
47
39
|
end
|
48
40
|
|
49
|
-
create_table
|
50
|
-
t.
|
51
|
-
t.string
|
52
|
-
t.
|
53
|
-
t.
|
54
|
-
t.
|
55
|
-
t.string "crypted_password", limit: 255, null: false
|
56
|
-
t.string "password_salt", limit: 255, null: false
|
57
|
-
t.string "persistence_token", limit: 255, null: false
|
58
|
-
t.string "single_access_token", limit: 255, null: false
|
59
|
-
t.string "perishable_token", limit: 255, null: false
|
60
|
-
t.integer "login_count", limit: 4, default: 0, null: false
|
61
|
-
t.integer "failed_login_count", limit: 4, default: 0, null: false
|
62
|
-
t.datetime "last_request_at"
|
63
|
-
t.datetime "current_login_at"
|
64
|
-
t.datetime "last_login_at"
|
65
|
-
t.string "current_login_ip", limit: 255
|
66
|
-
t.string "last_login_ip", limit: 255
|
67
|
-
t.datetime "created_at"
|
68
|
-
t.datetime "updated_at"
|
69
|
-
t.string "time_zone", limit: 255
|
70
|
-
t.integer "spud_role_id", limit: 4
|
71
|
-
t.boolean "requires_password_change", limit: 1, default: false
|
41
|
+
create_table 'spud_user_settings', force: :cascade do |t|
|
42
|
+
t.integer 'spud_user_id'
|
43
|
+
t.string 'key'
|
44
|
+
t.string 'value'
|
45
|
+
t.datetime 'created_at'
|
46
|
+
t.datetime 'updated_at'
|
72
47
|
end
|
73
48
|
|
74
|
-
|
75
|
-
|
76
|
-
|
49
|
+
create_table 'spud_users', force: :cascade do |t|
|
50
|
+
t.string 'first_name'
|
51
|
+
t.string 'last_name'
|
52
|
+
t.boolean 'super_admin'
|
53
|
+
t.string 'login', null: false
|
54
|
+
t.string 'email', null: false
|
55
|
+
t.string 'crypted_password', null: false
|
56
|
+
t.string 'password_salt', null: false
|
57
|
+
t.string 'persistence_token', null: false
|
58
|
+
t.string 'single_access_token', null: false
|
59
|
+
t.string 'perishable_token', null: false
|
60
|
+
t.integer 'login_count', default: 0, null: false
|
61
|
+
t.integer 'failed_login_count', default: 0, null: false
|
62
|
+
t.datetime 'last_request_at'
|
63
|
+
t.datetime 'current_login_at'
|
64
|
+
t.datetime 'last_login_at'
|
65
|
+
t.string 'current_login_ip'
|
66
|
+
t.string 'last_login_ip'
|
67
|
+
t.datetime 'created_at'
|
68
|
+
t.datetime 'updated_at'
|
69
|
+
t.string 'time_zone'
|
70
|
+
t.integer 'spud_role_id'
|
71
|
+
t.boolean 'requires_password_change', default: false
|
72
|
+
t.index ['email'], name: 'index_spud_users_on_email', using: :btree
|
73
|
+
t.index ['login'], name: 'index_spud_users_on_login', using: :btree
|
74
|
+
t.index ['spud_role_id'], name: 'index_spud_users_on_spud_role_id', using: :btree
|
75
|
+
end
|
77
76
|
|
78
77
|
end
|
@@ -24,8 +24,8 @@ FactoryGirl.define do
|
|
24
24
|
last_name { FactoryGirl.generate(:last_name) }
|
25
25
|
login { FactoryGirl.generate(:login) }
|
26
26
|
email { FactoryGirl.generate(:email) }
|
27
|
-
password
|
28
|
-
password_confirmation
|
27
|
+
password 'password'
|
28
|
+
password_confirmation 'password'
|
29
29
|
single_access_token { FactoryGirl.generate(:single_access_token) }
|
30
30
|
end
|
31
31
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe Admin::ApplicationHelper, :
|
3
|
+
describe Admin::ApplicationHelper, type: :helper do
|
4
4
|
describe '#timestamp' do
|
5
5
|
it "should return 'Never' if a timedate is not given" do
|
6
6
|
expect(timestamp).to eq('Never')
|
@@ -29,12 +29,12 @@ describe Admin::ApplicationHelper, :type => :helper do
|
|
29
29
|
@user = FactoryGirl.create(:spud_user)
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'should return blank when no errors exist' do
|
33
33
|
expect(helper.tb_form_errors(@user)).to be_blank
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
37
|
-
error =
|
36
|
+
it 'should display the error' do
|
37
|
+
error = 'Invalid!'
|
38
38
|
@user.errors[:base] << error
|
39
39
|
expect(helper.tb_form_errors(@user)).to include(error)
|
40
40
|
end
|
@@ -23,7 +23,7 @@ describe TbCore::BelongsToApp do
|
|
23
23
|
|
24
24
|
describe '#acts_as_app' do
|
25
25
|
it 'should configure the app' do
|
26
|
-
controller.current_user = FactoryGirl.create(:spud_user, :
|
26
|
+
controller.current_user = FactoryGirl.create(:spud_user, super_admin: true)
|
27
27
|
controller.send(:act_as_app, :users)
|
28
28
|
expect(controller.instance_variable_get('@page_application')).to be_a(Hash)
|
29
29
|
end
|
@@ -31,11 +31,11 @@ describe TbCore::BelongsToApp do
|
|
31
31
|
it 'should raise an error if the app cannot be found' do
|
32
32
|
expect{
|
33
33
|
controller.send(:act_as_app, :fail)
|
34
|
-
}.to raise_error
|
34
|
+
}.to raise_error(StandardError)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it 'should raise an error if the user does not have access' do
|
38
|
-
controller.current_user = FactoryGirl.create(:spud_user, :
|
38
|
+
controller.current_user = FactoryGirl.create(:spud_user, super_admin: false)
|
39
39
|
expect{
|
40
40
|
controller.send(:act_as_app, :users)
|
41
41
|
}.to raise_error(Spud::AccessDeniedError)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe SpudRole, :
|
3
|
+
describe SpudRole, type: :model do
|
4
4
|
|
5
5
|
before :each do
|
6
6
|
@role = FactoryGirl.build(:spud_role)
|
@@ -11,15 +11,15 @@ describe SpudRole, :type => :model do
|
|
11
11
|
@role.save()
|
12
12
|
end
|
13
13
|
|
14
|
-
describe
|
15
|
-
it
|
14
|
+
describe 'permissions' do
|
15
|
+
it 'should return an array of SpudPermission objects' do
|
16
16
|
expect(@role.permissions).to be_an_instance_of(Array)
|
17
17
|
expect(@role.permissions.first).to be_an_instance_of(SpudPermission)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
22
|
-
it
|
21
|
+
describe 'permissions=' do
|
22
|
+
it 'should update the SpudRolePermissions on the role' do
|
23
23
|
original_count = @role.spud_role_permissions.length
|
24
24
|
@role.permissions = [@full_access, @partial_access]
|
25
25
|
@role.save
|
@@ -27,15 +27,15 @@ describe SpudRole, :type => :model do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe
|
31
|
-
it
|
30
|
+
describe 'permission_tags' do
|
31
|
+
it 'should return an array of Strings' do
|
32
32
|
expect(@role.permission_tags).to be_an_instance_of(Array)
|
33
33
|
expect(@role.permission_tags.first).to be_an_instance_of(String)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe
|
38
|
-
it
|
37
|
+
describe 'permission_tags=' do
|
38
|
+
it 'should update the SpudRolePermissions on the role' do
|
39
39
|
original_count = @role.spud_role_permissions.length
|
40
40
|
@role.permission_tags = ['admin.test.full_access', 'admin.test.partial_access']
|
41
41
|
@role.save
|
@@ -1,60 +1,47 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe SpudUser, :
|
3
|
+
describe SpudUser, type: :model do
|
4
4
|
|
5
|
-
describe
|
6
|
-
it
|
5
|
+
describe '.full_name' do
|
6
|
+
it 'should return the full name if the first and last name are not blank' do
|
7
7
|
u = FactoryGirl.build(:spud_user)
|
8
8
|
expect(u.full_name).to eq("#{u.first_name} #{u.last_name}")
|
9
9
|
end
|
10
|
-
|
11
|
-
it
|
12
|
-
u = FactoryGirl.build(:spud_user, :
|
10
|
+
|
11
|
+
it 'should return only the last name if the first name is blank' do
|
12
|
+
u = FactoryGirl.build(:spud_user, first_name: nil)
|
13
13
|
expect(u.full_name).to eq(u.last_name)
|
14
14
|
end
|
15
|
-
|
16
|
-
it
|
17
|
-
u = FactoryGirl.build(:spud_user, :
|
15
|
+
|
16
|
+
it 'should return only the first name if the last name is blank' do
|
17
|
+
u = FactoryGirl.build(:spud_user, last_name: nil)
|
18
18
|
expect(u.full_name).to eq(u.first_name)
|
19
19
|
end
|
20
|
-
|
21
|
-
it "should return the login if the first and last name are blank" do
|
22
|
-
u = FactoryGirl.build(:spud_user, :first_name => nil, :last_name => nil)
|
23
|
-
expect(u.full_name).to eq(u.login)
|
24
|
-
end
|
25
|
-
end
|
26
20
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
expect(user.email_formatted).to eq("#{user.full_name} <#{user.email}>")
|
21
|
+
it 'should return the login if the first and last name are blank' do
|
22
|
+
u = FactoryGirl.build(:spud_user, first_name: nil, last_name: nil)
|
23
|
+
expect(u.full_name).to eq(u.login)
|
31
24
|
end
|
32
25
|
end
|
33
26
|
|
34
|
-
it
|
35
|
-
|
36
|
-
it { should validate_length_of(:password).is_at_least(4) }
|
37
|
-
it { should_not allow_value('@mail.com').for(:email) }
|
38
|
-
it { should_not allow_value('mail.com').for(:email) }
|
39
|
-
it { should allow_value('test@mail.com').for(:email) }
|
40
|
-
|
41
|
-
it "must match password confirmation before saving a new user" do
|
42
|
-
u = FactoryGirl.build(:spud_user, :password_confirmation => '')
|
27
|
+
it 'must match password confirmation before saving a new user' do
|
28
|
+
u = FactoryGirl.build(:spud_user, password_confirmation: '')
|
43
29
|
expect(u.save).to eq(false)
|
44
30
|
end
|
45
31
|
|
46
32
|
describe '#unset_requires_password_change' do
|
47
33
|
it 'should not unset the requires_password_change flag' do
|
48
|
-
u = FactoryGirl.create(:spud_user, :
|
34
|
+
u = FactoryGirl.create(:spud_user, requires_password_change: true)
|
49
35
|
expect{
|
50
|
-
u.update_attributes(:
|
36
|
+
u.update_attributes(first_name: 'updated')
|
51
37
|
}.to_not change(u, :requires_password_change)
|
52
38
|
end
|
53
39
|
|
54
40
|
it 'should unset the requires_password_change flag' do
|
55
|
-
u = FactoryGirl.create(:spud_user, :
|
41
|
+
u = FactoryGirl.create(:spud_user, requires_password_change: true)
|
56
42
|
expect{
|
57
|
-
u.update_attributes(:
|
43
|
+
u.update_attributes(password: 'new password', password_confirmation: 'new password')
|
44
|
+
u.reload
|
58
45
|
}.to change(u, :requires_password_change).from(true).to(false)
|
59
46
|
end
|
60
47
|
end
|
data/spec/rails_helper.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
-
ENV[
|
2
|
+
ENV['RAILS_ENV'] ||= 'test'
|
3
3
|
|
4
|
-
require File.expand_path(
|
4
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
5
5
|
require 'spec_helper'
|
6
6
|
# require 'session_helper'
|
7
7
|
require 'tb_core/test_helper'
|
8
|
+
require 'rails-controller-testing'
|
8
9
|
require 'rspec/rails'
|
9
10
|
require 'database_cleaner'
|
10
11
|
require 'simplecov'
|
11
12
|
require 'factory_girl_rails'
|
12
|
-
require 'shoulda'
|
13
13
|
|
14
14
|
SimpleCov.start 'rails'
|
15
15
|
|
@@ -37,11 +37,10 @@ SimpleCov.start 'rails'
|
|
37
37
|
RSpec.configure do |config|
|
38
38
|
config.raise_errors_for_deprecations!
|
39
39
|
config.infer_base_class_for_anonymous_controllers = false
|
40
|
-
|
40
|
+
|
41
41
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
42
42
|
# examples within a transaction, remove the following line or assign false
|
43
43
|
# instead of true.
|
44
|
-
config.use_transactional_fixtures = true
|
45
44
|
|
46
45
|
# RSpec Rails can automatically mix in different behaviours to your tests
|
47
46
|
# based on their file location, for example enabling you to call `get` and
|
@@ -69,5 +68,5 @@ RSpec.configure do |config|
|
|
69
68
|
example.run
|
70
69
|
end
|
71
70
|
end
|
72
|
-
|
71
|
+
|
73
72
|
end
|