strongbolt 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +56 -0
  3. data/.rubocop_todo.yml +91 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +18 -2
  6. data/Rakefile +1 -1
  7. data/app/controllers/strongbolt/capabilities_controller.rb +36 -45
  8. data/app/controllers/strongbolt/roles_controller.rb +39 -47
  9. data/app/controllers/strongbolt/security_controller.rb +2 -3
  10. data/app/controllers/strongbolt/user_groups_controller.rb +48 -54
  11. data/app/controllers/strongbolt/user_groups_users_controller.rb +2 -4
  12. data/app/controllers/strongbolt_controller.rb +1 -1
  13. data/circle.yml +13 -0
  14. data/lib/generators/strongbolt/fix_generator.rb +5 -6
  15. data/lib/generators/strongbolt/fix_unique_group_members_generator.rb +2 -3
  16. data/lib/generators/strongbolt/indexes_generator.rb +3 -4
  17. data/lib/generators/strongbolt/install_generator.rb +8 -9
  18. data/lib/generators/strongbolt/templates/fix_unique_group_members.rb +1 -1
  19. data/lib/generators/strongbolt/templates/indexes.rb +1 -1
  20. data/lib/generators/strongbolt/templates/migration.rb +11 -12
  21. data/lib/generators/strongbolt/templates/strongbolt.rb +1 -1
  22. data/lib/generators/strongbolt/views_generator.rb +4 -4
  23. data/lib/strongbolt.rb +51 -54
  24. data/lib/strongbolt/base.rb +1 -1
  25. data/lib/strongbolt/bolted.rb +12 -13
  26. data/lib/strongbolt/bolted_controller.rb +46 -57
  27. data/lib/strongbolt/capabilities_role.rb +5 -5
  28. data/lib/strongbolt/capability.rb +32 -31
  29. data/lib/strongbolt/configuration.rb +18 -19
  30. data/lib/strongbolt/controllers/url_helpers.rb +5 -5
  31. data/lib/strongbolt/engine.rb +9 -9
  32. data/lib/strongbolt/errors.rb +4 -4
  33. data/lib/strongbolt/generators/migration.rb +4 -6
  34. data/lib/strongbolt/helpers.rb +5 -7
  35. data/lib/strongbolt/rails/routes.rb +4 -4
  36. data/lib/strongbolt/role.rb +11 -12
  37. data/lib/strongbolt/roles_user_group.rb +5 -5
  38. data/lib/strongbolt/rspec.rb +2 -2
  39. data/lib/strongbolt/rspec/user.rb +13 -15
  40. data/lib/strongbolt/tenantable.rb +78 -80
  41. data/lib/strongbolt/user_abilities.rb +44 -54
  42. data/lib/strongbolt/user_group.rb +8 -10
  43. data/lib/strongbolt/user_groups_user.rb +6 -6
  44. data/lib/strongbolt/version.rb +1 -1
  45. data/lib/tasks/strongbolt_tasks.rake +4 -4
  46. data/spec/controllers/strongbolt/capabilities_controller_spec.rb +28 -45
  47. data/spec/controllers/strongbolt/roles_controller_spec.rb +39 -72
  48. data/spec/controllers/strongbolt/user_groups_controller_spec.rb +34 -65
  49. data/spec/controllers/strongbolt/user_groups_users_controller_spec.rb +11 -19
  50. data/spec/controllers/without_authorization_controller_spec.rb +5 -5
  51. data/spec/dummy/app/controllers/posts_controller.rb +2 -2
  52. data/spec/dummy/app/controllers/test_controller.rb +1 -1
  53. data/spec/dummy/app/controllers/without_authorization_controller.rb +1 -1
  54. data/spec/dummy/bin/rails +1 -1
  55. data/spec/dummy/config.ru +1 -1
  56. data/spec/dummy/config/application.rb +4 -5
  57. data/spec/dummy/config/initializers/cookies_serializer.rb +1 -1
  58. data/spec/dummy/config/initializers/strongbolt.rb +2 -2
  59. data/spec/dummy/config/routes.rb +1 -3
  60. data/spec/dummy/db/migrate/20150630212236_create_strongbolt_tables.rb +9 -10
  61. data/spec/dummy/db/migrate/20150630212251_create_strongbolt_tables_indexes.rb +2 -2
  62. data/spec/dummy/db/migrate/20160531110509_fix_unique_group_members.rb +1 -1
  63. data/spec/fabricators/capability_fabricator.rb +4 -4
  64. data/spec/fabricators/role_fabricator.rb +3 -3
  65. data/spec/fabricators/user_fabricator.rb +2 -2
  66. data/spec/fabricators/user_group_fabricator.rb +3 -3
  67. data/spec/fixtures/application.rb +6 -3
  68. data/spec/fixtures/controllers.rb +1 -1
  69. data/spec/spec_helper.rb +7 -8
  70. data/spec/strongbolt/bolted_controller_spec.rb +110 -208
  71. data/spec/strongbolt/bolted_spec.rb +26 -40
  72. data/spec/strongbolt/capability_spec.rb +72 -86
  73. data/spec/strongbolt/configuration_spec.rb +33 -46
  74. data/spec/strongbolt/controllers/url_helpers_spec.rb +7 -9
  75. data/spec/strongbolt/helpers_spec.rb +14 -16
  76. data/spec/strongbolt/role_spec.rb +32 -35
  77. data/spec/strongbolt/tenantable_spec.rb +88 -86
  78. data/spec/strongbolt/user_abilities_multiple_tenants_spec.rb +29 -34
  79. data/spec/strongbolt/user_abilities_spec.rb +142 -188
  80. data/spec/strongbolt/user_group_spec.rb +14 -14
  81. data/spec/strongbolt/users_tenant_spec.rb +10 -12
  82. data/spec/strongbolt_spec.rb +53 -73
  83. data/spec/support/controller_macros.rb +1 -3
  84. data/spec/support/db_setup.rb +31 -25
  85. data/spec/support/helpers.rb +12 -12
  86. data/spec/support/transactional_specs.rb +1 -3
  87. data/strongbolt.gemspec +14 -12
  88. metadata +20 -3
@@ -1,10 +1,8 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  module Strongbolt
4
-
5
4
  describe UserGroup do
6
-
7
- let(:user_group) { UserGroup.new name: "PCCC" }
5
+ let(:user_group) { UserGroup.new name: 'PCCC' }
8
6
 
9
7
  subject { user_group }
10
8
 
@@ -12,26 +10,28 @@ module Strongbolt
12
10
 
13
11
  it { is_expected.to validate_presence_of :name }
14
12
 
15
- it { is_expected.to have_many(:user_groups_users).class_name("Strongbolt::UserGroupsUser")
16
- .dependent :restrict_with_exception }
13
+ it {
14
+ is_expected.to have_many(:user_groups_users).class_name('Strongbolt::UserGroupsUser')
15
+ .dependent :restrict_with_exception
16
+ }
17
17
  it { is_expected.to have_many(:users).through :user_groups_users }
18
18
 
19
- it { is_expected.to have_many(:roles_user_groups).class_name("Strongbolt::RolesUserGroup")
20
- .dependent :delete_all }
19
+ it {
20
+ is_expected.to have_many(:roles_user_groups).class_name('Strongbolt::RolesUserGroup')
21
+ .dependent :delete_all
22
+ }
21
23
  it { is_expected.to have_many(:roles).through :roles_user_groups }
22
-
24
+
23
25
  it { is_expected.to have_many(:capabilities).through :roles }
24
26
 
25
- context "when there are users linked to it" do
27
+ context 'when there are users linked to it' do
26
28
  before { user_group.users << User.create! }
27
29
 
28
- it "cannot delete" do
30
+ it 'cannot delete' do
29
31
  expect do
30
32
  user_group.destroy
31
33
  end.to raise_error ActiveRecord::DeleteRestrictionError
32
34
  end
33
35
  end
34
-
35
36
  end
36
-
37
- end
37
+ end
@@ -1,18 +1,17 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Strongbolt::UsersTenant do
4
-
5
4
  before(:all) do
6
- define_model "TenantModel" do
7
- self.table_name = "models"
5
+ define_model 'TenantModel' do
6
+ self.table_name = 'models'
8
7
 
9
8
  tenant
10
9
  end
11
- define_model "Model" do
12
- self.table_name = "models"
10
+ define_model 'Model' do
11
+ self.table_name = 'models'
13
12
  end
14
13
  end
15
-
14
+
16
15
  let(:user) { User.create! }
17
16
  let(:tenant) { TenantModel.create! }
18
17
 
@@ -21,16 +20,15 @@ describe Strongbolt::UsersTenant do
21
20
  subject { users_tenant }
22
21
 
23
22
  it { is_expected.to belong_to :user }
24
- it { is_expected.to belong_to(:tenant_model).class_name("TenantModel") }
23
+ it { is_expected.to belong_to(:tenant_model).class_name('TenantModel') }
25
24
 
26
25
  it { is_expected.to be_valid }
27
26
  it { is_expected.to validate_presence_of :user }
28
27
  it { is_expected.to validate_presence_of :tenant_model }
29
28
 
30
- it "should ensure tenant is a Tenant" do
29
+ it 'should ensure tenant is a Tenant' do
31
30
  expect do
32
- users_tenant = Strongbolt::UsersTenantModel.new user: user, tenant_model: Model.create!
31
+ Strongbolt::UsersTenantModel.new user: user, tenant_model: Model.create!
33
32
  end.to raise_error ActiveRecord::AssociationTypeMismatch
34
33
  end
35
-
36
- end
34
+ end
@@ -1,19 +1,18 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Strongbolt do
4
-
5
4
  #
6
5
  # Important included modules
7
6
  #
8
- it "should have included Grant::Grantable in ActiveRecord::Base" do
7
+ it 'should have included Grant::Grantable in ActiveRecord::Base' do
9
8
  expect(ActiveRecord::Base.included_modules).to include Grant::Grantable
10
9
  end
11
10
 
12
- it "should have included Bolted in ActiveRecord::Base" do
11
+ it 'should have included Bolted in ActiveRecord::Base' do
13
12
  expect(ActiveRecord::Base.included_modules).to include Strongbolt::Bolted
14
13
  end
15
14
 
16
- it "should have included tentable" do
15
+ it 'should have included tentable' do
17
16
  expect(ActiveRecord::Base.included_modules).to include Strongbolt::Tenantable
18
17
  end
19
18
 
@@ -21,33 +20,30 @@ describe Strongbolt do
21
20
  # Setting up
22
21
  #
23
22
 
24
- describe "it should include module" do
23
+ describe 'it should include module' do
25
24
  before do
26
- define_model "UserModel"
25
+ define_model 'UserModel'
27
26
  Strongbolt.setup do |config|
28
- config.user_class = "UserModel"
27
+ config.user_class = 'UserModel'
29
28
  end
30
29
  end
31
30
  after do
32
31
  Strongbolt.setup do |config|
33
- config.user_class = "User"
32
+ config.user_class = 'User'
34
33
  end
35
34
  end
36
35
 
37
- it "should include UserAbilities" do
36
+ it 'should include UserAbilities' do
38
37
  expect(UserModel.included_modules).to include Strongbolt::UserAbilities
39
38
  end
40
-
41
-
42
39
  end
43
40
 
44
41
  #
45
42
  # Access denied
46
43
  #
47
- describe "access denied" do
48
-
44
+ describe 'access denied' do
49
45
  before do
50
- block = double('block', :call => nil)
46
+ block = double('block', call: nil)
51
47
  expect(block).to receive(:call).with 'user', 'instance', 'action', 'request_path'
52
48
  Strongbolt::Configuration.access_denied do |user, instance, action, request_path|
53
49
  block.call user, instance, action, request_path
@@ -58,22 +54,19 @@ describe Strongbolt do
58
54
  it "should call configuration's block" do
59
55
  Strongbolt.access_denied 'user', 'instance', 'action', 'request_path'
60
56
  end
61
-
62
57
  end
63
58
 
64
-
65
-
66
59
  #
67
60
  # Without authorization
68
61
  #
69
- describe "without_authorization" do
70
- it "should not perform authorization" do
62
+ describe 'without_authorization' do
63
+ it 'should not perform authorization' do
71
64
  Strongbolt.without_authorization do
72
65
  expect(Grant::Status.grant_disabled?).to eq true
73
66
  end
74
67
  end
75
68
 
76
- describe "perform action" do
69
+ describe 'perform action' do
77
70
  before do
78
71
  @user = User.create!
79
72
  Strongbolt.current_user = User.create!
@@ -83,73 +76,71 @@ describe Strongbolt do
83
76
  let(:user) { @user }
84
77
 
85
78
  context 'with authorization' do
86
- it "should call user can? when normal" do
79
+ it 'should call user can? when normal' do
87
80
  expect_any_instance_of(User).to receive(:can?)
88
81
  .with(:find, user).and_return true
89
82
  User.find user.id
90
83
  end
91
84
  end
92
85
 
93
- context "when without_authorization" do
94
- it "should not call can?" do
86
+ context 'when without_authorization' do
87
+ it 'should not call can?' do
95
88
  Strongbolt.without_authorization do
96
89
  expect_any_instance_of(User).not_to receive(:can?)
97
- expect(User.find user.id).to eq user
90
+ expect(User.find(user.id)).to eq user
98
91
  end
99
92
  end
100
93
  end
101
94
  end
102
95
  end
103
96
 
104
-
105
97
  #
106
98
  # Perform without authorization
107
99
  #
108
- describe "perform_without_authorization" do
100
+ describe 'perform_without_authorization' do
109
101
  before do
110
- define("AnyClass", Object) do
111
- def method arg1, arg2, &block
102
+ define('AnyClass', Object) do
103
+ def method(_arg1, _arg2)
112
104
  raise StandardError if Grant::Status.grant_enabled?
113
105
  end
114
106
  end
115
107
  end
116
108
 
117
- context "when not skipped" do
118
- it "should raise error" do
109
+ context 'when not skipped' do
110
+ it 'should raise error' do
119
111
  expect do
120
- AnyClass.new.method("ok", "ok2") {}
112
+ AnyClass.new.method('ok', 'ok2') {}
121
113
  end.to raise_error(StandardError)
122
114
  end
123
115
  end
124
116
 
125
- context "when skipped" do
117
+ context 'when skipped' do
126
118
  before { AnyClass.perform_without_authorization :method }
127
119
 
128
- it "should skip authorization" do
120
+ it 'should skip authorization' do
129
121
  expect do
130
- AnyClass.new.method("ok", "ok2") {}
122
+ AnyClass.new.method('ok', 'ok2') {}
131
123
  end.not_to raise_error
132
124
  end
133
125
  end
134
126
  end
135
127
 
136
-
137
128
  #
138
129
  # Disable, enable
139
130
  #
140
- describe "disable/enable" do
131
+ describe 'disable/enable' do
141
132
  before { Strongbolt.disable_authorization }
142
133
  after { Strongbolt.enable_authorization }
143
134
 
144
- context "disabling" do
145
- it "should disable Grant" do
135
+ context 'disabling' do
136
+ it 'should disable Grant' do
146
137
  expect(Grant::Status.grant_enabled?).to eq false
147
138
  expect(Strongbolt.enabled?).to eq false
148
139
  end
149
140
  end
150
141
 
151
- context "enabling" do
152
- it "should enable Grant" do
142
+ context 'enabling' do
143
+ it 'should enable Grant' do
153
144
  Strongbolt.enable_authorization
154
145
  expect(Grant::Status.grant_disabled?).to eq false
155
146
  expect(Strongbolt.disabled?).to eq false
@@ -157,34 +148,30 @@ describe Strongbolt do
157
148
  end
158
149
  end
159
150
 
160
-
161
-
162
151
  #
163
152
  # Setting the Grant user
164
153
  #
165
154
  describe 'setting the current user' do
166
-
167
- context "when it is from the same class then defined (or default)" do
168
-
155
+ context 'when it is from the same class then defined (or default)' do
169
156
  context "when the model doesn't have the module UserAbilities included" do
170
157
  before do
171
- define_model "UserWithout" do
158
+ define_model 'UserWithout' do
172
159
  self.table_name = 'users'
173
160
  end
174
161
 
175
162
  # We configure the user class
176
163
  Strongbolt::Configuration.user_class = 'UserWithout'
177
164
  end
178
- after { undefine_model "UserWithout" }
165
+ after { undefine_model 'UserWithout' }
179
166
 
180
167
  let(:user) { UserWithout.new }
181
168
 
182
- it "should have included the module" do
169
+ it 'should have included the module' do
183
170
  Strongbolt.current_user = user
184
171
  expect(UserWithout.included_modules).to include Strongbolt::UserAbilities
185
172
  end
186
173
 
187
- it "should set the current user" do
174
+ it 'should set the current user' do
188
175
  Strongbolt.current_user = user
189
176
  expect(Strongbolt.current_user).to eq user
190
177
  expect(Grant::User.current_user).to eq user
@@ -192,9 +179,8 @@ describe Strongbolt do
192
179
  end # End when User Class doesn't have the UserAbilities included
193
180
 
194
181
  context 'when the model has the UserAbilities module included' do
195
-
196
182
  before do
197
- define_model "UserWithAbilities" do
183
+ define_model 'UserWithAbilities' do
198
184
  include Strongbolt::UserAbilities
199
185
  self.table_name = 'users'
200
186
  end
@@ -202,73 +188,67 @@ describe Strongbolt do
202
188
  # We configure the user class
203
189
  Strongbolt::Configuration.user_class = 'UserWithAbilities'
204
190
  end
205
- after { undefine_model "UserWithAbilities" }
191
+ after { undefine_model 'UserWithAbilities' }
206
192
 
207
193
  let(:user) { UserWithAbilities.new }
208
194
 
209
- it "should set the current user" do
195
+ it 'should set the current user' do
210
196
  Strongbolt.current_user = user
211
197
  expect(Strongbolt.current_user).to eq user
212
198
  expect(Grant::User.current_user).to eq user
213
199
  end
214
-
215
200
  end # End when User class has Abilities
216
201
 
217
- context "when the user model is the base class of a STI" do
202
+ context 'when the user model is the base class of a STI' do
218
203
  before do
219
- define_model "BaseUser" do
204
+ define_model 'BaseUser' do
220
205
  self.table_name = 'users'
221
206
  end
222
- define "UserWithSTI", BaseUser do
207
+ define 'UserWithSTI', BaseUser do
223
208
  end
224
209
  Strongbolt::Configuration.user_class = 'BaseUser'
225
210
  end
226
211
 
227
212
  let(:user) { UserWithSTI.new }
228
213
 
229
- it "should allow setting as user a subclass" do
214
+ it 'should allow setting as user a subclass' do
230
215
  Strongbolt.current_user = user
231
216
  expect(Strongbolt.current_user).to eq user
232
217
  end
233
- end #/ end when user model is the base class of a STI
218
+ end # / end when user model is the base class of a STI
234
219
 
235
- context "when the user model is a subclass of a STI" do
220
+ context 'when the user model is a subclass of a STI' do
236
221
  before do
237
- define_model "BaseUser" do
222
+ define_model 'BaseUser' do
238
223
  self.table_name = 'users'
239
224
  end
240
- define "UserWithSTI", BaseUser do
225
+ define 'UserWithSTI', BaseUser do
241
226
  end
242
- Strongbolt::Configuration.user_class = "UserWithSTI"
227
+ Strongbolt::Configuration.user_class = 'UserWithSTI'
243
228
  end
244
229
 
245
230
  let(:user) { UserWithSTI.new }
246
231
 
247
- it "should allow setting as user a subclass" do
232
+ it 'should allow setting as user a subclass' do
248
233
  Strongbolt.current_user = user
249
234
  expect(Strongbolt.current_user).to eq user
250
235
  end
251
236
 
252
- it "should not allos the base class" do
237
+ it 'should not allos the base class' do
253
238
  expect do
254
239
  Strongbolt.current_user = BaseUser.new
255
240
  end.to raise_error Strongbolt::WrongUserClass
256
241
  end
257
- end #/ end when user model is the base class of a STI
258
-
242
+ end # / end when user model is the base class of a STI
259
243
  end # End when user given is the right class
260
244
 
261
245
  context "when the model isn't from the user class" do
262
-
263
- it "should raise error" do
246
+ it 'should raise error' do
264
247
  Strongbolt::Configuration.user_class = 'User'
265
248
  expect do
266
249
  Strongbolt.current_user = Model.new
267
250
  end.to raise_error Strongbolt::WrongUserClass
268
251
  end
269
-
270
252
  end
271
-
272
253
  end
273
-
274
254
  end
@@ -1,5 +1,4 @@
1
1
  module ControllerMacros
2
-
3
2
  def login_user
4
3
  before(:each) do
5
4
  @user = Fabricate :user
@@ -7,5 +6,4 @@ module ControllerMacros
7
6
  end
8
7
  let(:current_user) { @user }
9
8
  end
10
-
11
- end
9
+ end
@@ -6,12 +6,12 @@ FileUtils.mkdir(tmpdir) unless File.exist?(tmpdir)
6
6
  test_db = File.join(tmpdir, 'test.db')
7
7
 
8
8
  connection_spec = {
9
- :adapter => 'sqlite3',
10
- :database => test_db
9
+ adapter: 'sqlite3',
10
+ database: test_db
11
11
  }
12
12
 
13
13
  # Delete any existing instance of the test database
14
- FileUtils.rm test_db, :force => true
14
+ FileUtils.rm test_db, force: true
15
15
 
16
16
  # Create a new test database
17
17
  ActiveRecord::Base.establish_connection(connection_spec)
@@ -20,13 +20,13 @@ ActiveRecord::Base.establish_connection(connection_spec)
20
20
 
21
21
  class TestsMigrations < ActiveRecord::Migration
22
22
  def change
23
- create_table :users, :force => true do |t|
23
+ create_table :users, force: true do |t|
24
24
  t.string :username
25
25
 
26
26
  t.timestamps
27
27
  end
28
28
 
29
- create_table :models, :force => true do |t|
29
+ create_table :models, force: true do |t|
30
30
  t.string :name
31
31
  t.string :value
32
32
  t.integer :user_id
@@ -35,7 +35,7 @@ class TestsMigrations < ActiveRecord::Migration
35
35
  t.timestamps
36
36
  end
37
37
 
38
- create_table :child_models, :force => true do |t|
38
+ create_table :child_models, force: true do |t|
39
39
  t.integer :model_id
40
40
  t.string :model_type
41
41
  t.integer :parent_id
@@ -43,31 +43,40 @@ class TestsMigrations < ActiveRecord::Migration
43
43
  t.timestamps
44
44
  end
45
45
 
46
- create_table :unowned_models, :force => true do |t|
46
+ create_table :other_child_models, force: true do |t|
47
+ t.integer :model_id
48
+ t.string :model_type
49
+ t.integer :other_model_id
50
+ t.string :other_model_type
51
+
52
+ t.timestamps
53
+ end
54
+
55
+ create_table :unowned_models, force: true do |t|
47
56
  t.string :name
48
57
  t.string :value
49
58
 
50
59
  t.timestamps
51
60
  end
52
61
 
53
- create_table :model_models, :force => true do |t|
62
+ create_table :model_models, force: true do |t|
54
63
  t.integer :parent_id
55
64
  t.integer :child_id
56
65
  end
57
66
 
58
- create_table :tenant_a, :force => true do |t|
67
+ create_table :tenant_a, force: true do |t|
59
68
  t.string :name
60
69
 
61
70
  t.timestamps
62
71
  end
63
72
 
64
- create_table :tenant_b, :force => true do |t|
73
+ create_table :tenant_b, force: true do |t|
65
74
  t.string :name
66
75
 
67
76
  t.timestamps
68
77
  end
69
78
 
70
- create_table :model_with_tenants, :force => true do |t|
79
+ create_table :model_with_tenants, force: true do |t|
71
80
  t.string :name
72
81
  t.integer :tenant_a_id
73
82
  t.integer :tenant_b_id
@@ -75,19 +84,19 @@ class TestsMigrations < ActiveRecord::Migration
75
84
  t.timestamps
76
85
  end
77
86
 
78
- create_table :strongbolt_capabilities, :force => true do |t|
87
+ create_table :strongbolt_capabilities, force: true do |t|
79
88
  t.string :name
80
89
  t.string :description
81
90
  t.string :model
82
91
  t.string :action
83
92
  t.string :attr
84
- t.boolean :require_ownership, :default => false, :null => false
85
- t.boolean :require_tenant_access, :default => true, :null => false
93
+ t.boolean :require_ownership, default: false, null: false
94
+ t.boolean :require_tenant_access, default: true, null: false
86
95
 
87
96
  t.timestamps
88
97
  end
89
98
 
90
- create_table :strongbolt_roles, :force => true do |t|
99
+ create_table :strongbolt_roles, force: true do |t|
91
100
  t.string :name
92
101
  t.integer :parent_id
93
102
  t.integer :lft
@@ -97,29 +106,29 @@ class TestsMigrations < ActiveRecord::Migration
97
106
  t.timestamps
98
107
  end
99
108
 
100
- create_table :strongbolt_user_groups, :force => true do |t|
109
+ create_table :strongbolt_user_groups, force: true do |t|
101
110
  t.string :name
102
111
  t.text :description
103
112
 
104
113
  t.timestamps
105
114
  end
106
115
 
107
- create_table :strongbolt_user_groups_users, :force => true do |t|
116
+ create_table :strongbolt_user_groups_users, force: true do |t|
108
117
  t.integer :user_group_id
109
118
  t.integer :user_id
110
119
  end
111
120
 
112
- create_table :strongbolt_roles_user_groups, :force => true do |t|
121
+ create_table :strongbolt_roles_user_groups, force: true do |t|
113
122
  t.integer :user_group_id
114
123
  t.integer :role_id
115
124
  end
116
125
 
117
- create_table :strongbolt_capabilities_roles, :force => true do |t|
126
+ create_table :strongbolt_capabilities_roles, force: true do |t|
118
127
  t.integer :role_id
119
128
  t.integer :capability_id
120
129
  end
121
130
 
122
- create_table :strongbolt_users_tenants, :force => true do |t|
131
+ create_table :strongbolt_users_tenants, force: true do |t|
123
132
  t.integer :user_id
124
133
  t.integer :tenant_id
125
134
  t.string :type
@@ -142,15 +151,12 @@ class TestsMigrations < ActiveRecord::Migration
142
151
  add_index :strongbolt_users_tenants, :user_id
143
152
  add_index :strongbolt_users_tenants, :tenant_id
144
153
  add_index :strongbolt_users_tenants, :type
145
- add_index :strongbolt_users_tenants, [:tenant_id, :type]
154
+ add_index :strongbolt_users_tenants, %i[tenant_id type]
146
155
 
147
- add_index :strongbolt_user_groups_users, [:user_group_id, :user_id], unique: true, name: :index_strongbolt_user_groups_users_unique
156
+ add_index :strongbolt_user_groups_users, %i[user_group_id user_id], unique: true, name: :index_strongbolt_user_groups_users_unique
148
157
  end
149
158
  end
150
159
 
151
160
  class User < ActiveRecord::Base; end
152
161
  class Model < ActiveRecord::Base; end
153
162
  class UnownedModel < ActiveRecord::Base; end
154
-
155
-
156
-