curupira 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of curupira might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/views/curupira/roles/show.html.erb +1 -1
- data/lib/curupira/authorizer.rb +1 -1
- data/lib/curupira/version.rb +1 -1
- data/spec/curupira/full_feature_spec.rb +24 -0
- data/spec/dummy/config/locales/en.yml +21 -1
- data/spec/dummy/db/seeds.rb +37 -137
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f14fa682e08b79b040066b77987f1e349d6f7fc
|
4
|
+
data.tar.gz: 1e079aeade659aa49a9a845685bb729ab32fd547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d0748f95cd07df56e5c71e7010a6d5c8c0fc3ee87431916e7892ef623b7d2acc49e06871044ab302739a5bdebd86c51eb1131ac4b9bc875be19cc87f1b29b31
|
7
|
+
data.tar.gz: d22e13945075d7f2e9cd8c5725140c6f2884e57bc4134bd5c0bd654dbf5506770c68c8cb737a6d2735438ee565f7cdc8c49350684b39a72cbe71612739497597
|
data/Gemfile.lock
CHANGED
data/lib/curupira/authorizer.rb
CHANGED
data/lib/curupira/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
require "curupira/authorizer"
|
3
|
+
|
4
|
+
describe Curupira::Authorizer do
|
5
|
+
include Curupira::Authorizer
|
6
|
+
|
7
|
+
describe "#has_authorization?" do
|
8
|
+
let!(:current_user) { FactoryGirl.create(:user) }
|
9
|
+
let(:params) do
|
10
|
+
{
|
11
|
+
controller: "users",
|
12
|
+
action: "create"
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
setup_authorization(current_user, "users", "manage")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "have authorization" do
|
21
|
+
expect(has_authorization?).to be true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -20,4 +20,24 @@
|
|
20
20
|
# available at http://guides.rubyonrails.org/i18n.html.
|
21
21
|
|
22
22
|
en:
|
23
|
-
hello:
|
23
|
+
hello: 'OLA'
|
24
|
+
curupira:
|
25
|
+
features:
|
26
|
+
curupira/users:
|
27
|
+
create: "Create Users"
|
28
|
+
show: "Show Users"
|
29
|
+
edit: "Edit User"
|
30
|
+
delete: "Remove User"
|
31
|
+
manage: "Manage User"
|
32
|
+
curupira/groups:
|
33
|
+
create: "Create Groups"
|
34
|
+
show: "Show Groups"
|
35
|
+
edit: "Edit Group"
|
36
|
+
delete: "Remove Group"
|
37
|
+
manage: "Manage Groups"
|
38
|
+
curupira/roles:
|
39
|
+
create: "Create Roles"
|
40
|
+
show: "Show Roles"
|
41
|
+
edit: "Edit Role"
|
42
|
+
delete: "Remove Role"
|
43
|
+
manage: "Manage Roles"
|
data/spec/dummy/db/seeds.rb
CHANGED
@@ -1,137 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
feature.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
action_1 = ActionLabel.create name: "new"
|
39
|
-
action_2 = ActionLabel.create name: "create"
|
40
|
-
|
41
|
-
feature.action_labels = [action_1, action_2]
|
42
|
-
|
43
|
-
feature.save
|
44
|
-
|
45
|
-
feature = Feature.create name: "Visualizar Perfis", controller: "curupira/roles"
|
46
|
-
|
47
|
-
action_1 = ActionLabel.create name: "index"
|
48
|
-
action_2 = ActionLabel.create name: "show"
|
49
|
-
|
50
|
-
feature.action_labels = [action_1, action_2]
|
51
|
-
|
52
|
-
feature.save
|
53
|
-
|
54
|
-
feature = Feature.create name: "Editar Perfis", controller: "curupira/roles"
|
55
|
-
|
56
|
-
action_1 = ActionLabel.create name: "edit"
|
57
|
-
action_2 = ActionLabel.create name: "update"
|
58
|
-
|
59
|
-
feature.action_labels = [action_1, action_2]
|
60
|
-
|
61
|
-
feature = Feature.create name: "Deletar Perfis", controller: "curupira/roles"
|
62
|
-
|
63
|
-
action_1 = ActionLabel.create name: "destroy"
|
64
|
-
|
65
|
-
feature.action_labels = [action_1]
|
66
|
-
|
67
|
-
feature.save
|
68
|
-
|
69
|
-
###############################################
|
70
|
-
|
71
|
-
feature = Feature.create name: "Cadastrar Grupos", controller: "curupira/groups"
|
72
|
-
|
73
|
-
action_1 = ActionLabel.create name: "new"
|
74
|
-
action_2 = ActionLabel.create name: "create"
|
75
|
-
|
76
|
-
feature.action_labels = [action_1, action_2]
|
77
|
-
|
78
|
-
feature.save
|
79
|
-
|
80
|
-
feature = Feature.create name: "Visualizar Grupos", controller: "curupira/groups"
|
81
|
-
|
82
|
-
action_1 = ActionLabel.create name: "index"
|
83
|
-
action_2 = ActionLabel.create name: "show"
|
84
|
-
|
85
|
-
feature.action_labels = [action_1, action_2]
|
86
|
-
|
87
|
-
feature.save
|
88
|
-
|
89
|
-
feature = Feature.create name: "Editar Grupos", controller: "curupira/groups"
|
90
|
-
|
91
|
-
action_1 = ActionLabel.create name: "edit"
|
92
|
-
action_2 = ActionLabel.create name: "update"
|
93
|
-
|
94
|
-
feature.action_labels = [action_1, action_2]
|
95
|
-
|
96
|
-
feature = Feature.create name: "Deletar Grupos", controller: "curupira/groups"
|
97
|
-
|
98
|
-
action_1 = ActionLabel.create name: "destroy"
|
99
|
-
|
100
|
-
feature.action_labels = [action_1]
|
101
|
-
|
102
|
-
feature.save
|
103
|
-
|
104
|
-
###############################################
|
105
|
-
|
106
|
-
feature = Feature.create name: "Cadastrar Grupos", controller: "curupira/groups"
|
107
|
-
|
108
|
-
action_1 = ActionLabel.create name: "new"
|
109
|
-
action_2 = ActionLabel.create name: "create"
|
110
|
-
|
111
|
-
feature.action_labels = [action_1, action_2]
|
112
|
-
|
113
|
-
feature.save
|
114
|
-
|
115
|
-
feature = Feature.create name: "Visualizar Grupos", controller: "curupira/groups"
|
116
|
-
|
117
|
-
action_1 = ActionLabel.create name: "index"
|
118
|
-
action_2 = ActionLabel.create name: "show"
|
119
|
-
|
120
|
-
feature.action_labels = [action_1, action_2]
|
121
|
-
|
122
|
-
feature.save
|
123
|
-
|
124
|
-
feature = Feature.create name: "Editar Grupos", controller: "curupira/groups"
|
125
|
-
|
126
|
-
action_1 = ActionLabel.create name: "edit"
|
127
|
-
action_2 = ActionLabel.create name: "update"
|
128
|
-
|
129
|
-
feature.action_labels = [action_1, action_2]
|
130
|
-
|
131
|
-
feature = Feature.create name: "Deletar Grupos", controller: "curupira/groups"
|
132
|
-
|
133
|
-
action_1 = ActionLabel.create name: "destroy"
|
134
|
-
|
135
|
-
feature.action_labels = [action_1]
|
136
|
-
|
137
|
-
feature.save
|
1
|
+
Rails.application.eager_load!
|
2
|
+
|
3
|
+
def eval_curupira_action(controller, action)
|
4
|
+
case action.to_s
|
5
|
+
when "index", "show", "search"
|
6
|
+
feature_desc = I18n.t("curupira.features.#{controller}.show")
|
7
|
+
when "create", "new"
|
8
|
+
feature_desc = I18n.t("curupira.features.#{controller}.create")
|
9
|
+
when "edit", "update"
|
10
|
+
feature_desc = I18n.t("curupira.features.#{controller}.edit")
|
11
|
+
when "delete", "destroy"
|
12
|
+
feature_desc = I18n.t("curupira.features.#{controller}.delete")
|
13
|
+
else
|
14
|
+
feature_desc = "Other: " << action.to_s
|
15
|
+
end
|
16
|
+
return feature_desc
|
17
|
+
end
|
18
|
+
|
19
|
+
Curupira::AuthorizedController.subclasses.each do |controller|
|
20
|
+
p clazz = controller.to_s.underscore.gsub("_controller", "")
|
21
|
+
|
22
|
+
feature = Feature.create name: I18n.t("curupira.features.#{clazz}.manage"), controller: clazz
|
23
|
+
feature.action_labels << ActionLabel.create(name: "manage")
|
24
|
+
|
25
|
+
controller.action_methods.each do |action|
|
26
|
+
feature_description = eval_curupira_action(clazz, action)
|
27
|
+
|
28
|
+
feature = Feature.find_by(name: feature_description)
|
29
|
+
|
30
|
+
if feature.present?
|
31
|
+
feature.action_labels << ActionLabel.create(name: action)
|
32
|
+
else
|
33
|
+
feature = Feature.create name: feature_description, controller: clazz
|
34
|
+
feature.action_labels << ActionLabel.create(name: action)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curupira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Moura
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-03-
|
14
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- spec/controllers/sessions_controller_spec.rb
|
218
218
|
- spec/controllers/users_controller_spec.rb
|
219
219
|
- spec/curupira/authorization_spec.rb
|
220
|
+
- spec/curupira/full_feature_spec.rb
|
220
221
|
- spec/dummy/README.rdoc
|
221
222
|
- spec/dummy/Rakefile
|
222
223
|
- spec/dummy/app/assets/images/.keep
|
@@ -349,15 +350,15 @@ files:
|
|
349
350
|
- spec/tmp/app/models/user.rb
|
350
351
|
- spec/tmp/config/initializers/sorcery.rb
|
351
352
|
- spec/tmp/config/routes.rb
|
352
|
-
- spec/tmp/db/migrate/
|
353
|
-
- spec/tmp/db/migrate/
|
354
|
-
- spec/tmp/db/migrate/
|
355
|
-
- spec/tmp/db/migrate/
|
356
|
-
- spec/tmp/db/migrate/
|
357
|
-
- spec/tmp/db/migrate/
|
358
|
-
- spec/tmp/db/migrate/
|
359
|
-
- spec/tmp/db/migrate/
|
360
|
-
- spec/tmp/db/migrate/
|
353
|
+
- spec/tmp/db/migrate/20150320032239_create_role_group_users.rb
|
354
|
+
- spec/tmp/db/migrate/20150320032240_create_authorizations.rb
|
355
|
+
- spec/tmp/db/migrate/20150320032241_create_features.rb
|
356
|
+
- spec/tmp/db/migrate/20150320032242_create_groups.rb
|
357
|
+
- spec/tmp/db/migrate/20150320032243_create_roles.rb
|
358
|
+
- spec/tmp/db/migrate/20150320032244_sorcery_core.rb
|
359
|
+
- spec/tmp/db/migrate/20150320032245_create_group_users.rb
|
360
|
+
- spec/tmp/db/migrate/20150320032246_create_role_groups.rb
|
361
|
+
- spec/tmp/db/migrate/20150320032247_create_action_labels.rb
|
361
362
|
homepage: https://rubygems.org/gems/curupira
|
362
363
|
licenses:
|
363
364
|
- MIT
|
@@ -402,6 +403,7 @@ test_files:
|
|
402
403
|
- spec/controllers/sessions_controller_spec.rb
|
403
404
|
- spec/controllers/users_controller_spec.rb
|
404
405
|
- spec/curupira/authorization_spec.rb
|
406
|
+
- spec/curupira/full_feature_spec.rb
|
405
407
|
- spec/dummy/app/assets/javascripts/application.js
|
406
408
|
- spec/dummy/app/assets/stylesheets/application.css
|
407
409
|
- spec/dummy/app/controllers/application_controller.rb
|
@@ -528,12 +530,12 @@ test_files:
|
|
528
530
|
- spec/tmp/app/models/user.rb
|
529
531
|
- spec/tmp/config/initializers/sorcery.rb
|
530
532
|
- spec/tmp/config/routes.rb
|
531
|
-
- spec/tmp/db/migrate/
|
532
|
-
- spec/tmp/db/migrate/
|
533
|
-
- spec/tmp/db/migrate/
|
534
|
-
- spec/tmp/db/migrate/
|
535
|
-
- spec/tmp/db/migrate/
|
536
|
-
- spec/tmp/db/migrate/
|
537
|
-
- spec/tmp/db/migrate/
|
538
|
-
- spec/tmp/db/migrate/
|
539
|
-
- spec/tmp/db/migrate/
|
533
|
+
- spec/tmp/db/migrate/20150320032239_create_role_group_users.rb
|
534
|
+
- spec/tmp/db/migrate/20150320032240_create_authorizations.rb
|
535
|
+
- spec/tmp/db/migrate/20150320032241_create_features.rb
|
536
|
+
- spec/tmp/db/migrate/20150320032242_create_groups.rb
|
537
|
+
- spec/tmp/db/migrate/20150320032243_create_roles.rb
|
538
|
+
- spec/tmp/db/migrate/20150320032244_sorcery_core.rb
|
539
|
+
- spec/tmp/db/migrate/20150320032245_create_group_users.rb
|
540
|
+
- spec/tmp/db/migrate/20150320032246_create_role_groups.rb
|
541
|
+
- spec/tmp/db/migrate/20150320032247_create_action_labels.rb
|