strongbolt 0.3.12 → 0.3.13
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/.rubocop.yml +56 -0
- data/.rubocop_todo.yml +91 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +18 -2
- data/Rakefile +1 -1
- data/app/controllers/strongbolt/capabilities_controller.rb +36 -45
- data/app/controllers/strongbolt/roles_controller.rb +39 -47
- data/app/controllers/strongbolt/security_controller.rb +2 -3
- data/app/controllers/strongbolt/user_groups_controller.rb +48 -54
- data/app/controllers/strongbolt/user_groups_users_controller.rb +2 -4
- data/app/controllers/strongbolt_controller.rb +1 -1
- data/circle.yml +13 -0
- data/lib/generators/strongbolt/fix_generator.rb +5 -6
- data/lib/generators/strongbolt/fix_unique_group_members_generator.rb +2 -3
- data/lib/generators/strongbolt/indexes_generator.rb +3 -4
- data/lib/generators/strongbolt/install_generator.rb +8 -9
- data/lib/generators/strongbolt/templates/fix_unique_group_members.rb +1 -1
- data/lib/generators/strongbolt/templates/indexes.rb +1 -1
- data/lib/generators/strongbolt/templates/migration.rb +11 -12
- data/lib/generators/strongbolt/templates/strongbolt.rb +1 -1
- data/lib/generators/strongbolt/views_generator.rb +4 -4
- data/lib/strongbolt.rb +51 -54
- data/lib/strongbolt/base.rb +1 -1
- data/lib/strongbolt/bolted.rb +12 -13
- data/lib/strongbolt/bolted_controller.rb +46 -57
- data/lib/strongbolt/capabilities_role.rb +5 -5
- data/lib/strongbolt/capability.rb +32 -31
- data/lib/strongbolt/configuration.rb +18 -19
- data/lib/strongbolt/controllers/url_helpers.rb +5 -5
- data/lib/strongbolt/engine.rb +9 -9
- data/lib/strongbolt/errors.rb +4 -4
- data/lib/strongbolt/generators/migration.rb +4 -6
- data/lib/strongbolt/helpers.rb +5 -7
- data/lib/strongbolt/rails/routes.rb +4 -4
- data/lib/strongbolt/role.rb +11 -12
- data/lib/strongbolt/roles_user_group.rb +5 -5
- data/lib/strongbolt/rspec.rb +2 -2
- data/lib/strongbolt/rspec/user.rb +13 -15
- data/lib/strongbolt/tenantable.rb +78 -80
- data/lib/strongbolt/user_abilities.rb +44 -54
- data/lib/strongbolt/user_group.rb +8 -10
- data/lib/strongbolt/user_groups_user.rb +6 -6
- data/lib/strongbolt/version.rb +1 -1
- data/lib/tasks/strongbolt_tasks.rake +4 -4
- data/spec/controllers/strongbolt/capabilities_controller_spec.rb +28 -45
- data/spec/controllers/strongbolt/roles_controller_spec.rb +39 -72
- data/spec/controllers/strongbolt/user_groups_controller_spec.rb +34 -65
- data/spec/controllers/strongbolt/user_groups_users_controller_spec.rb +11 -19
- data/spec/controllers/without_authorization_controller_spec.rb +5 -5
- data/spec/dummy/app/controllers/posts_controller.rb +2 -2
- data/spec/dummy/app/controllers/test_controller.rb +1 -1
- data/spec/dummy/app/controllers/without_authorization_controller.rb +1 -1
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/config/application.rb +4 -5
- data/spec/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/spec/dummy/config/initializers/strongbolt.rb +2 -2
- data/spec/dummy/config/routes.rb +1 -3
- data/spec/dummy/db/migrate/20150630212236_create_strongbolt_tables.rb +9 -10
- data/spec/dummy/db/migrate/20150630212251_create_strongbolt_tables_indexes.rb +2 -2
- data/spec/dummy/db/migrate/20160531110509_fix_unique_group_members.rb +1 -1
- data/spec/fabricators/capability_fabricator.rb +4 -4
- data/spec/fabricators/role_fabricator.rb +3 -3
- data/spec/fabricators/user_fabricator.rb +2 -2
- data/spec/fabricators/user_group_fabricator.rb +3 -3
- data/spec/fixtures/application.rb +6 -3
- data/spec/fixtures/controllers.rb +1 -1
- data/spec/spec_helper.rb +7 -8
- data/spec/strongbolt/bolted_controller_spec.rb +110 -208
- data/spec/strongbolt/bolted_spec.rb +26 -40
- data/spec/strongbolt/capability_spec.rb +72 -86
- data/spec/strongbolt/configuration_spec.rb +33 -46
- data/spec/strongbolt/controllers/url_helpers_spec.rb +7 -9
- data/spec/strongbolt/helpers_spec.rb +14 -16
- data/spec/strongbolt/role_spec.rb +32 -35
- data/spec/strongbolt/tenantable_spec.rb +88 -86
- data/spec/strongbolt/user_abilities_multiple_tenants_spec.rb +29 -34
- data/spec/strongbolt/user_abilities_spec.rb +142 -188
- data/spec/strongbolt/user_group_spec.rb +14 -14
- data/spec/strongbolt/users_tenant_spec.rb +10 -12
- data/spec/strongbolt_spec.rb +53 -73
- data/spec/support/controller_macros.rb +1 -3
- data/spec/support/db_setup.rb +31 -25
- data/spec/support/helpers.rb +12 -12
- data/spec/support/transactional_specs.rb +1 -3
- data/strongbolt.gemspec +14 -12
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7327ac274c00438b501748f6f93f57237710e630
|
4
|
+
data.tar.gz: ba02bcccd69e25f437e0d9cee195bf8b326c1b83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2699cb99bba155a48cf9bc82281d0fe2f1babc575bdb82ba88b5af722e0f8f471b5e835a25f872fcbe608a3d895e3fe039b74bb3b0559719c2e0cd997e73c0b2
|
7
|
+
data.tar.gz: d70f5117422b493c5cf568970adab8c3ffee464aaa16c9049d56e93b0473bcc995c71f3856acd31de09e3c9da7833fdc6cb9b8a11c070652cd0028c95bd9ca11
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
Exclude:
|
5
|
+
- 'bin/**/*'
|
6
|
+
- 'vendor/**/*'
|
7
|
+
- 'lib/generators/strongbolt/templates/strongbolt.rb'
|
8
|
+
- 'spec/dummy/db/schema.rb'
|
9
|
+
|
10
|
+
# Cop names are not displayed in offense messages by default. Change behavior
|
11
|
+
# by overriding DisplayCopNames, or by giving the -D/--display-cop-names
|
12
|
+
# option.
|
13
|
+
DisplayCopNames: false
|
14
|
+
|
15
|
+
Metrics/AbcSize:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Metrics/BlockLength:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Metrics/BlockNesting:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Metrics/ClassLength:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Metrics/CyclomaticComplexity:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Metrics/LineLength:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Metrics/MethodLength:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Metrics/ModuleLength:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Metrics/ParameterLists:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Metrics/PerceivedComplexity:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Style/ClassVars:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Style/Documentation:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Style/FrozenStringLiteralComment:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Style/RedundantSelf:
|
55
|
+
Enabled: false
|
56
|
+
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2017-07-10 16:50:49 +0200 using RuboCop version 0.49.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 3
|
10
|
+
Lint/HandleExceptions:
|
11
|
+
Exclude:
|
12
|
+
- 'lib/strongbolt/bolted_controller.rb'
|
13
|
+
- 'spec/support/helpers.rb'
|
14
|
+
|
15
|
+
# Offense count: 1
|
16
|
+
Lint/LiteralInCondition:
|
17
|
+
Exclude:
|
18
|
+
- 'lib/strongbolt/rspec/user.rb'
|
19
|
+
|
20
|
+
# Offense count: 1
|
21
|
+
Lint/ShadowingOuterLocalVariable:
|
22
|
+
Exclude:
|
23
|
+
- 'lib/strongbolt/tenantable.rb'
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
Lint/UselessAssignment:
|
27
|
+
Exclude:
|
28
|
+
- 'lib/strongbolt/user_abilities.rb'
|
29
|
+
|
30
|
+
# Offense count: 1
|
31
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
32
|
+
# SupportedStyles: nested, compact
|
33
|
+
Style/ClassAndModuleChildren:
|
34
|
+
Exclude:
|
35
|
+
- 'lib/strongbolt/rails/routes.rb'
|
36
|
+
|
37
|
+
# Offense count: 1
|
38
|
+
# Configuration parameters: AllowedVariables.
|
39
|
+
Style/GlobalVars:
|
40
|
+
Exclude:
|
41
|
+
- 'spec/strongbolt/bolted_controller_spec.rb'
|
42
|
+
|
43
|
+
# Offense count: 8
|
44
|
+
# Configuration parameters: MinBodyLength.
|
45
|
+
Style/GuardClause:
|
46
|
+
Exclude:
|
47
|
+
- 'lib/strongbolt/bolted_controller.rb'
|
48
|
+
- 'lib/strongbolt/capability.rb'
|
49
|
+
- 'lib/strongbolt/configuration.rb'
|
50
|
+
- 'lib/strongbolt/role.rb'
|
51
|
+
- 'lib/strongbolt/rspec/user.rb'
|
52
|
+
- 'lib/strongbolt/tenantable.rb'
|
53
|
+
|
54
|
+
# Offense count: 5
|
55
|
+
Style/IdenticalConditionalBranches:
|
56
|
+
Exclude:
|
57
|
+
- 'lib/strongbolt/rspec/user.rb'
|
58
|
+
- 'lib/strongbolt/user_abilities.rb'
|
59
|
+
|
60
|
+
# Offense count: 2
|
61
|
+
# Cop supports --auto-correct.
|
62
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
63
|
+
# SupportedStyles: line_count_dependent, lambda, literal
|
64
|
+
Style/Lambda:
|
65
|
+
Exclude:
|
66
|
+
- 'lib/strongbolt/capability.rb'
|
67
|
+
- 'lib/strongbolt/tenantable.rb'
|
68
|
+
|
69
|
+
# Offense count: 1
|
70
|
+
Style/MethodMissing:
|
71
|
+
Exclude:
|
72
|
+
- 'lib/strongbolt/configuration.rb'
|
73
|
+
|
74
|
+
# Offense count: 1
|
75
|
+
# Cop supports --auto-correct.
|
76
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
|
77
|
+
# SupportedStyles: predicate, comparison
|
78
|
+
Style/NumericPredicate:
|
79
|
+
Exclude:
|
80
|
+
- 'spec/**/*'
|
81
|
+
- 'lib/strongbolt/role.rb'
|
82
|
+
|
83
|
+
# Offense count: 1
|
84
|
+
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
|
85
|
+
# NamePrefix: is_, has_, have_
|
86
|
+
# NamePrefixBlacklist: is_, has_, have_
|
87
|
+
# NameWhitelist: is_a?
|
88
|
+
Style/PredicateName:
|
89
|
+
Exclude:
|
90
|
+
- 'spec/**/*'
|
91
|
+
- 'lib/strongbolt/user_abilities.rb'
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
strongbolt (0.3.
|
4
|
+
strongbolt (0.3.12)
|
5
5
|
awesome_nested_set (~> 3.1.0)
|
6
6
|
grant (~> 3.0)
|
7
7
|
simple_form (~> 3.0)
|
@@ -36,6 +36,7 @@ GEM
|
|
36
36
|
thread_safe (~> 0.1)
|
37
37
|
tzinfo (~> 1.1)
|
38
38
|
arel (5.0.1.20140414130214)
|
39
|
+
ast (2.3.0)
|
39
40
|
awesome_nested_set (3.1.1)
|
40
41
|
activerecord (>= 4.0.0, < 5.1)
|
41
42
|
builder (3.2.2)
|
@@ -57,6 +58,10 @@ GEM
|
|
57
58
|
mime-types-data (~> 3.2015)
|
58
59
|
mime-types-data (3.2016.0521)
|
59
60
|
minitest (5.9.0)
|
61
|
+
parallel (1.11.2)
|
62
|
+
parser (2.4.0.0)
|
63
|
+
ast (~> 2.2)
|
64
|
+
powerpack (0.1.1)
|
60
65
|
rack (1.5.5)
|
61
66
|
rack-test (0.6.3)
|
62
67
|
rack (>= 1.0)
|
@@ -75,6 +80,8 @@ GEM
|
|
75
80
|
activesupport (= 4.1.15)
|
76
81
|
rake (>= 0.8.7)
|
77
82
|
thor (>= 0.18.1, < 2.0)
|
83
|
+
rainbow (2.2.2)
|
84
|
+
rake
|
78
85
|
rake (11.2.2)
|
79
86
|
rspec (3.5.0)
|
80
87
|
rspec-core (~> 3.5.0)
|
@@ -97,6 +104,13 @@ GEM
|
|
97
104
|
rspec-mocks (~> 3.5.0)
|
98
105
|
rspec-support (~> 3.5.0)
|
99
106
|
rspec-support (3.5.0)
|
107
|
+
rubocop (0.49.1)
|
108
|
+
parallel (~> 1.10)
|
109
|
+
parser (>= 2.3.3.1, < 3.0)
|
110
|
+
powerpack (~> 0.1)
|
111
|
+
rainbow (>= 1.99.1, < 3.0)
|
112
|
+
ruby-progressbar (~> 1.7)
|
113
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
100
114
|
ruby-progressbar (1.8.1)
|
101
115
|
shoulda-matchers (2.7.0)
|
102
116
|
activesupport (>= 3.0.0)
|
@@ -115,6 +129,7 @@ GEM
|
|
115
129
|
thread_safe (0.3.5)
|
116
130
|
tzinfo (1.2.2)
|
117
131
|
thread_safe (~> 0.1)
|
132
|
+
unicode-display_width (1.3.0)
|
118
133
|
|
119
134
|
PLATFORMS
|
120
135
|
ruby
|
@@ -127,9 +142,10 @@ DEPENDENCIES
|
|
127
142
|
rails (~> 4.1.0)
|
128
143
|
rake
|
129
144
|
rspec-rails
|
145
|
+
rubocop
|
130
146
|
shoulda-matchers (~> 2.7.0)
|
131
147
|
sqlite3
|
132
148
|
strongbolt!
|
133
149
|
|
134
150
|
BUNDLED WITH
|
135
|
-
1.
|
151
|
+
1.15.0
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module Strongbolt
|
2
|
-
|
3
2
|
class CapabilitiesController < ::StrongboltController
|
4
|
-
|
5
3
|
def index
|
6
4
|
@capabilities = Capability.all
|
7
5
|
end
|
@@ -11,67 +9,60 @@ module Strongbolt
|
|
11
9
|
end
|
12
10
|
|
13
11
|
def create
|
14
|
-
|
15
|
-
@capability = Capability.where(capability_params).first_or_create
|
12
|
+
@capability = Capability.where(capability_params).first_or_create
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
# If we have a role id, we add the capability to the role
|
15
|
+
if params[:role_id].present?
|
16
|
+
@role = Role.find params[:role_id]
|
17
|
+
@role.capabilities << @capability
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
else
|
27
|
-
redirect_to capabilities_path
|
19
|
+
respond_to do |format|
|
20
|
+
format.html { redirect_to role_path(@role) }
|
21
|
+
format.json { head :ok }
|
28
22
|
end
|
29
|
-
|
30
|
-
flash[:danger] = "Permission could not be created: ERROR #{e}"
|
23
|
+
else
|
31
24
|
redirect_to capabilities_path
|
32
25
|
end
|
26
|
+
rescue ActionController::ParameterMissing => e
|
27
|
+
flash[:danger] = "Permission could not be created: ERROR #{e}"
|
28
|
+
redirect_to capabilities_path
|
33
29
|
end
|
34
30
|
|
35
31
|
def destroy
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
if params[:role_id].present?
|
40
|
-
@role = Role.find params[:role_id]
|
32
|
+
# If we're passed a role id
|
33
|
+
if params[:role_id].present?
|
34
|
+
@role = Role.find params[:role_id]
|
41
35
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
conditions = if params[:id].present?
|
37
|
+
{ id: params[:id] }
|
38
|
+
else
|
39
|
+
capability_params
|
40
|
+
end
|
47
41
|
|
48
|
-
|
49
|
-
|
42
|
+
@capability = @role.capabilities.find_by(conditions)
|
43
|
+
@role.capabilities.delete @capability
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
else
|
56
|
-
@capability = Capability.find params[:id]
|
57
|
-
@capability.destroy
|
58
|
-
|
59
|
-
redirect_to capabilities_path
|
45
|
+
respond_to do |format|
|
46
|
+
format.html { redirect_to role_path(@role) }
|
47
|
+
format.json { head :ok }
|
60
48
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
49
|
+
else
|
50
|
+
@capability = Capability.find params[:id]
|
51
|
+
@capability.destroy
|
52
|
+
|
53
|
+
redirect_to capabilities_path
|
65
54
|
end
|
55
|
+
rescue ActiveRecord::DeleteRestrictionError
|
56
|
+
flash[:danger] = 'Permission has roles using it, delete relationships before deleting it'
|
57
|
+
|
58
|
+
redirect_to capability_path(@capability)
|
66
59
|
end
|
67
60
|
|
68
61
|
private
|
69
62
|
|
70
63
|
def capability_params
|
71
64
|
params.require(:capability).permit(:model, :action,
|
72
|
-
|
65
|
+
:require_ownership, :require_tenant_access)
|
73
66
|
end
|
74
|
-
|
75
67
|
end
|
76
|
-
|
77
|
-
end
|
68
|
+
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module Strongbolt
|
2
2
|
class RolesController < ::StrongboltController
|
3
|
-
|
4
3
|
def index
|
5
4
|
@roles = Role.includes(:parent)
|
6
|
-
|
5
|
+
.order('parent_id IS NOT NULL', 'parent_id', 'name')
|
7
6
|
end
|
8
7
|
|
9
8
|
def new
|
@@ -26,58 +25,52 @@ module Strongbolt
|
|
26
25
|
end
|
27
26
|
|
28
27
|
def create
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
redirect_to edit_role_path(@role)
|
43
|
-
end
|
28
|
+
@role = Role.create! role_params
|
29
|
+
|
30
|
+
flash[:success] = 'Role was successfully created!'
|
31
|
+
redirect_to role_path(@role)
|
32
|
+
rescue ActiveRecord::RecordInvalid
|
33
|
+
flash[:danger] = 'Role could not be created, please review the errors below'
|
34
|
+
redirect_to new_role_path
|
35
|
+
rescue ActionController::ParameterMissing => e
|
36
|
+
flash[:danger] = "Role could not be created: ERROR #{e}"
|
37
|
+
redirect_to new_role_path
|
38
|
+
rescue ActiveRecord::ActiveRecordError
|
39
|
+
flash[:danger] = 'The parent you selected leads to an impossible configuration'
|
40
|
+
redirect_to edit_role_path(@role)
|
44
41
|
end
|
45
42
|
|
46
43
|
def update
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
redirect_to edit_role_path(@role)
|
62
|
-
end
|
44
|
+
@role = Role.find params[:id]
|
45
|
+
@role.update_attributes! role_params
|
46
|
+
|
47
|
+
flash[:success] = 'Role was successfully updated!'
|
48
|
+
redirect_to role_path(@role)
|
49
|
+
rescue ActiveRecord::RecordInvalid
|
50
|
+
flash[:danger] = 'Role could not be updated, please review the errors below'
|
51
|
+
redirect_to edit_role_path(@role)
|
52
|
+
rescue ActionController::ParameterMissing => e
|
53
|
+
flash[:danger] = "Role could not be updated: ERROR #{e}"
|
54
|
+
redirect_to edit_role_path(@role)
|
55
|
+
rescue ActiveRecord::ActiveRecordError
|
56
|
+
flash[:danger] = 'The parent you selected leads to an impossible configuration'
|
57
|
+
redirect_to edit_role_path(@role)
|
63
58
|
end
|
64
59
|
|
65
60
|
def destroy
|
66
|
-
|
67
|
-
|
68
|
-
@role.destroy!
|
61
|
+
@role = Role.find params[:id]
|
62
|
+
@role.destroy!
|
69
63
|
|
70
|
-
|
64
|
+
flash[:success] = "Role #{@role.name} successfully deleted"
|
71
65
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
66
|
+
redirect_to roles_path
|
67
|
+
rescue ActiveRecord::DeleteRestrictionError
|
68
|
+
flash[:danger] = "Role #{@role.name} could not be deleted because #{@role.user_groups.size} user groups rely on it"
|
69
|
+
redirect_to role_path(@role)
|
77
70
|
end
|
78
71
|
|
79
|
-
rescue_from ActiveRecord::RecordNotFound do |
|
80
|
-
flash[:danger] =
|
72
|
+
rescue_from ActiveRecord::RecordNotFound do |_e|
|
73
|
+
flash[:danger] = 'Could not find role.'
|
81
74
|
redirect_to roles_path
|
82
75
|
end
|
83
76
|
|
@@ -85,8 +78,7 @@ module Strongbolt
|
|
85
78
|
|
86
79
|
def role_params
|
87
80
|
params.require(:role).permit(:name, :parent_id, :description,
|
88
|
-
|
81
|
+
capability_ids: [])
|
89
82
|
end
|
90
|
-
|
91
83
|
end
|
92
|
-
end
|
84
|
+
end
|