the_role 2.5.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +178 -526
  3. data/gem_version.rb +3 -0
  4. data/lib/the_role/version.rb +1 -3
  5. data/lib/the_role.rb +3 -41
  6. data/the_role.gemspec +5 -5
  7. metadata +20 -231
  8. data/.ruby-gemset.example +0 -1
  9. data/.ruby-version.example +0 -1
  10. data/.rvmrc.example +0 -1
  11. data/.travis.yml +0 -5
  12. data/Bye_bye_CanCan_I_got_the_Role.png +0 -0
  13. data/app/controllers/admin/role_sections_controller.rb +0 -90
  14. data/app/controllers/admin/roles_controller.rb +0 -74
  15. data/app/controllers/concerns/controller.rb +0 -23
  16. data/app/models/_templates_/role.rb +0 -3
  17. data/app/models/concerns/base.rb +0 -37
  18. data/app/models/concerns/role.rb +0 -156
  19. data/app/models/concerns/user.rb +0 -57
  20. data/config/locales/en.yml +0 -44
  21. data/config/locales/es.yml +0 -42
  22. data/config/locales/nl.yml +0 -44
  23. data/config/locales/pl.yml +0 -43
  24. data/config/locales/pt_BR.yml +0 -43
  25. data/config/locales/ru.yml +0 -43
  26. data/config/locales/zh_CN.yml +0 -42
  27. data/config/routes.rb +0 -23
  28. data/db/migrate/20111025025129_create_roles.rb +0 -23
  29. data/docs/2.1.1.png +0 -0
  30. data/lib/generators/the_role/USAGE +0 -32
  31. data/lib/generators/the_role/templates/the_role.rb +0 -11
  32. data/lib/generators/the_role/the_role_generator.rb +0 -64
  33. data/lib/tasks/roles.rake +0 -137
  34. data/lib/the_role/activerecord.rb +0 -11
  35. data/lib/the_role/config.rb +0 -30
  36. data/lib/the_role/hash.rb +0 -58
  37. data/lib/the_role/the_class_exists.rb +0 -8
  38. data/pic.png +0 -0
  39. data/spec/dummy_app/.gitignore +0 -18
  40. data/spec/dummy_app/.rspec +0 -1
  41. data/spec/dummy_app/Gemfile +0 -43
  42. data/spec/dummy_app/README.md +0 -39
  43. data/spec/dummy_app/Rakefile +0 -6
  44. data/spec/dummy_app/app/assets/images/.keep +0 -0
  45. data/spec/dummy_app/app/assets/javascripts/application.js +0 -17
  46. data/spec/dummy_app/app/assets/stylesheets/app/style.css.scss +0 -23
  47. data/spec/dummy_app/app/assets/stylesheets/application.css +0 -3
  48. data/spec/dummy_app/app/controllers/application_controller.rb +0 -38
  49. data/spec/dummy_app/app/controllers/concerns/.keep +0 -0
  50. data/spec/dummy_app/app/controllers/pages_controller.rb +0 -75
  51. data/spec/dummy_app/app/controllers/users_controller.rb +0 -32
  52. data/spec/dummy_app/app/controllers/welcome_controller.rb +0 -13
  53. data/spec/dummy_app/app/helpers/application_helper.rb +0 -2
  54. data/spec/dummy_app/app/mailers/.keep +0 -0
  55. data/spec/dummy_app/app/models/.keep +0 -0
  56. data/spec/dummy_app/app/models/concerns/.keep +0 -0
  57. data/spec/dummy_app/app/models/page.rb +0 -24
  58. data/spec/dummy_app/app/models/role.rb +0 -4
  59. data/spec/dummy_app/app/models/user.rb +0 -21
  60. data/spec/dummy_app/app/views/layouts/_current_user_info.html.haml +0 -17
  61. data/spec/dummy_app/app/views/layouts/application.html.haml +0 -68
  62. data/spec/dummy_app/app/views/pages/_form.html.haml +0 -19
  63. data/spec/dummy_app/app/views/pages/edit.html.haml +0 -7
  64. data/spec/dummy_app/app/views/pages/index.html.haml +0 -27
  65. data/spec/dummy_app/app/views/pages/manage.html.haml +0 -23
  66. data/spec/dummy_app/app/views/pages/my.html.haml +0 -10
  67. data/spec/dummy_app/app/views/pages/new.html.haml +0 -5
  68. data/spec/dummy_app/app/views/pages/show.html.haml +0 -15
  69. data/spec/dummy_app/app/views/users/edit.html.haml +0 -34
  70. data/spec/dummy_app/app/views/welcome/index.html.haml +0 -38
  71. data/spec/dummy_app/app/views/welcome/profile.html.haml +0 -2
  72. data/spec/dummy_app/bin/bundle +0 -3
  73. data/spec/dummy_app/bin/rails +0 -4
  74. data/spec/dummy_app/bin/rake +0 -4
  75. data/spec/dummy_app/config/application.rb +0 -25
  76. data/spec/dummy_app/config/boot.rb +0 -4
  77. data/spec/dummy_app/config/database.yml +0 -17
  78. data/spec/dummy_app/config/environment.rb +0 -5
  79. data/spec/dummy_app/config/environments/development.rb +0 -29
  80. data/spec/dummy_app/config/environments/production.rb +0 -80
  81. data/spec/dummy_app/config/environments/test.rb +0 -36
  82. data/spec/dummy_app/config/initializers/backtrace_silencers.rb +0 -7
  83. data/spec/dummy_app/config/initializers/devise.rb +0 -227
  84. data/spec/dummy_app/config/initializers/filter_parameter_logging.rb +0 -4
  85. data/spec/dummy_app/config/initializers/inflections.rb +0 -16
  86. data/spec/dummy_app/config/initializers/mime_types.rb +0 -5
  87. data/spec/dummy_app/config/initializers/secret_token.rb +0 -12
  88. data/spec/dummy_app/config/initializers/session_store.rb +0 -3
  89. data/spec/dummy_app/config/initializers/the_role.rb +0 -6
  90. data/spec/dummy_app/config/initializers/wrap_parameters.rb +0 -14
  91. data/spec/dummy_app/config/locales/devise.en.yml +0 -57
  92. data/spec/dummy_app/config/locales/en.yml +0 -7
  93. data/spec/dummy_app/config/locales/ru.yml +0 -4
  94. data/spec/dummy_app/config/routes.rb +0 -26
  95. data/spec/dummy_app/config.ru +0 -4
  96. data/spec/dummy_app/db/migrate/20120212061952_devise_create_users.rb +0 -63
  97. data/spec/dummy_app/db/migrate/20120212063249_create_roles.rb +0 -18
  98. data/spec/dummy_app/db/migrate/20120314061307_create_pages.rb +0 -14
  99. data/spec/dummy_app/db/schema.rb +0 -59
  100. data/spec/dummy_app/db/seeds.rb +0 -85
  101. data/spec/dummy_app/lib/assets/.keep +0 -0
  102. data/spec/dummy_app/lib/tasks/.keep +0 -0
  103. data/spec/dummy_app/lib/tasks/assets.rake +0 -15
  104. data/spec/dummy_app/lib/tasks/db_bootstrap.rake +0 -16
  105. data/spec/dummy_app/log/.keep +0 -0
  106. data/spec/dummy_app/public/404.html +0 -58
  107. data/spec/dummy_app/public/422.html +0 -58
  108. data/spec/dummy_app/public/500.html +0 -57
  109. data/spec/dummy_app/public/favicon.ico +0 -0
  110. data/spec/dummy_app/public/robots.txt +0 -5
  111. data/spec/dummy_app/spec/controllers/admin_roles_controller_spec.rb +0 -52
  112. data/spec/dummy_app/spec/controllers/pages_controller_spec.rb +0 -141
  113. data/spec/dummy_app/spec/controllers/welcome_controller_spec.rb +0 -66
  114. data/spec/dummy_app/spec/factories/page.rb +0 -6
  115. data/spec/dummy_app/spec/factories/role.rb +0 -55
  116. data/spec/dummy_app/spec/factories/user.rb +0 -11
  117. data/spec/dummy_app/spec/models/hash_spec.rb +0 -272
  118. data/spec/dummy_app/spec/models/param_process_spec.rb +0 -39
  119. data/spec/dummy_app/spec/models/role_spec.rb +0 -218
  120. data/spec/dummy_app/spec/models/user_spec.rb +0 -164
  121. data/spec/dummy_app/spec/routing/admin_roles_routing_spec.rb +0 -41
  122. data/spec/dummy_app/spec/routing/pages_routing_spec.rb +0 -35
  123. data/spec/dummy_app/spec/spec_helper.rb +0 -68
  124. data/spec/dummy_app/vendor/assets/javascripts/.keep +0 -0
  125. data/spec/dummy_app/vendor/assets/stylesheets/.keep +0 -0
  126. data/the_role.yml.teamocil.example +0 -11
@@ -1,16 +0,0 @@
1
- namespace :db do
2
- # rake db:bootstrap
3
- desc "Reset DB"
4
- task bootstrap: :environment do
5
- Rake::Task["db:drop"].invoke
6
- Rake::Task["db:create"].invoke
7
- Rake::Task["db:migrate"].invoke
8
- end
9
-
10
- # rake db:bootstrap_and_seed
11
- desc "Reset DB and seed"
12
- task bootstrap_and_seed: :environment do
13
- Rake::Task["db:bootstrap"].invoke
14
- Rake::Task["db:seed"].invoke
15
- end
16
- end
File without changes
@@ -1,58 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/404.html -->
52
- <div class="dialog">
53
- <h1>The page you were looking for doesn't exist.</h1>
54
- <p>You may have mistyped the address or the page may have moved.</p>
55
- </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
- </body>
58
- </html>
@@ -1,58 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/422.html -->
52
- <div class="dialog">
53
- <h1>The change you wanted was rejected.</h1>
54
- <p>Maybe you tried to change something you didn't have access to.</p>
55
- </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
- </body>
58
- </html>
@@ -1,57 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/500.html -->
52
- <div class="dialog">
53
- <h1>We're sorry, but something went wrong.</h1>
54
- </div>
55
- <p>If you are the application owner check the logs for more information.</p>
56
- </body>
57
- </html>
File without changes
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-agent: *
5
- # Disallow: /
@@ -1,52 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Admin::RolesController do
4
- describe "Admin Section" do
5
- describe 'Unauthorized' do
6
- before(:each) do
7
- @request.env['HTTP_REFERER'] = '/'
8
- @role = FactoryGirl.create(:role_user)
9
- end
10
-
11
- %w{ index new }.each do |action|
12
- it action.upcase do
13
- get action
14
- response.should redirect_to new_user_session_path
15
- end
16
- end
17
-
18
- %w{ edit update create destroy }.each do |action|
19
- it action.upcase do
20
- get action, { id: @role.id }
21
- response.should redirect_to new_user_session_path
22
- end
23
- end
24
- end
25
-
26
- describe "Authorized / Regular user" do
27
- describe "Can't do something with Roles" do
28
- before(:each) do
29
- @request.env['HTTP_REFERER'] = '/'
30
- @user = FactoryGirl.create(:user)
31
- @role = FactoryGirl.create(:role_user)
32
- sign_in @user
33
- end
34
-
35
- %w{ index new }.each do |action|
36
- it action.upcase do
37
- get action
38
- response.body.should match access_denied_match
39
- end
40
- end
41
-
42
- %w{ edit update create destroy }.each do |action|
43
- it action.upcase do
44
- get action, { id: @role.id }
45
- response.body.should match access_denied_match
46
- end
47
- end
48
- end
49
- end
50
-
51
- end
52
- end
@@ -1,141 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PagesController do
4
- def valid_page_attrs
5
- {
6
- title: Faker::Lorem.sentence,
7
- content: Faker::Lorem.sentence,
8
- state: :published
9
- }
10
- end
11
-
12
- def valid_page_for user
13
- valid_page_attrs.merge(user_id: user.id)
14
- end
15
-
16
- before(:each) do
17
- @role = FactoryGirl.create(:role_user)
18
- @moderator_role = FactoryGirl.create(:role_moderator)
19
-
20
- @owner = FactoryGirl.create(:user, role: @role)
21
- @hacker = FactoryGirl.create(:user, role: @role)
22
- @moderator = FactoryGirl.create(:user, role: @moderator_role)
23
-
24
- @owner.pages.create! valid_page_for(@owner)
25
- end
26
-
27
- describe "Guest" do
28
- describe 'NOT AUTORIZED/NO ROLE/NOT OWNER' do
29
- it "CREATE / but should be redirected" do
30
- post :create, { page: { fake: true } }
31
- response.should redirect_to new_user_session_path
32
- end
33
- end
34
- end
35
-
36
- describe "User" do
37
- describe 'AUTORIZED/HAS ROLE/OWNER' do
38
- before(:each) { sign_in @owner }
39
-
40
- context "CREATE" do
41
- it "valid" do
42
- expect {
43
- post :create , { page: valid_page_for(@owner) }
44
- }.to change(Page, :count).by(1)
45
- end
46
-
47
- it "invalid params" do
48
- expect {
49
- post :create, { page: { fake: true } }
50
- }.to_not change(Page, :count)
51
-
52
- response.should render_template :new
53
- end
54
-
55
- it "valid, no errors" do
56
- post :create , { page: valid_page_for(@owner) }
57
- assigns(:page).errors.should be_empty
58
- end
59
-
60
- it "valid, redirect to SHOW" do
61
- post :create, { page: valid_page_for(@owner) }
62
- response.should redirect_to page_path assigns(:page)
63
- end
64
- end
65
-
66
- context "UPDATE" do
67
- before(:each) do
68
- sign_in @owner
69
- @page = @owner.pages.last
70
- end
71
-
72
- it "users should has rules" do
73
- @owner.has_role?(:pages, :update).should be_true
74
- @hacker.has_role?(:pages, :update).should be_true
75
- end
76
-
77
- it "page should be updated" do
78
- old_title = @page.title
79
- new_title = "test_title"
80
-
81
- expect {
82
- patch :update, id: @page, page: { title: new_title }
83
- @page.reload
84
- }.to change(@page, :title).from(old_title).to(new_title)
85
- end
86
- end
87
- end
88
-
89
- describe 'AUTORIZED/HAS ROLE/NOT OWNER' do
90
- before(:each) { @page = @owner.pages.last }
91
-
92
- it "hacker should be blocked" do
93
- sign_in @hacker
94
- @request.env['HTTP_REFERER'] = '/'
95
- patch :update, id: @page, page: { title: "test_title" }
96
- response.body.should match access_denied_match
97
- end
98
- end
99
- end
100
-
101
- describe "Moderator" do
102
- before(:each) do
103
- @page = @owner.pages.last
104
-
105
- @old_title = @page.title
106
- @new_title = Faker::Lorem.sentence
107
- end
108
-
109
- it "Owner can update page" do
110
- sign_in @owner
111
-
112
- expect {
113
- patch :update, id: @page, page: { title: @new_title }
114
- @page.reload
115
- }.to change(@page, :title).from(@old_title).to(@new_title)
116
- end
117
-
118
- it "Moderator can update page" do
119
- sign_in @moderator
120
-
121
- expect {
122
- patch :update, id: @page, page: { title: @new_title }
123
- @page.reload
124
- }.to change(@page, :title).from(@old_title).to(@new_title)
125
- end
126
-
127
- it "Hacker cant update page" do
128
- sign_in @hacker
129
- @request.env['HTTP_REFERER'] = '/'
130
-
131
- expect {
132
- patch :update, id: @page, page: { title: @new_title }
133
- @page.reload
134
- }.to_not change(@page, :title).from(@old_title).to(@new_title)
135
- end
136
- end
137
- end
138
-
139
- # assigns(:page).should eq @page
140
- # response.should render_template :manage
141
- # response.should redirect_to new_user_session_path
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe WelcomeController do
4
- describe "GET for GUESTS" do
5
- it "*INDEX* test *subject* object" do
6
- get 'index'
7
- subject.class.should == WelcomeController
8
- end
9
-
10
- it "*INDEX* returns http success" do
11
- get 'index'
12
- response.should be_success
13
- end
14
-
15
- it "*INDEX* render :index page" do
16
- get 'index'
17
- response.should render_template :index
18
- end
19
-
20
- it "*INDEX* *current_user* should be nil" do
21
- get 'index'
22
- subject.current_user.should be_nil
23
- end
24
-
25
- it "*PROFILE* will be redirect" do
26
- get 'profile'
27
- response.should be_redirect
28
- end
29
-
30
- it "*PROFILE* will be redirect to new_user_session_path page" do
31
- get 'profile'
32
- response.should redirect_to new_user_session_path
33
- end
34
- end
35
-
36
- describe "GET for LOGGED_IN users" do
37
- before(:each) do
38
- @user = FactoryGirl.create(:user)
39
- sign_in @user
40
- end
41
-
42
- after(:each) do
43
- User.destroy_all
44
- end
45
-
46
- it "One user should be exists" do
47
- User.count.should be 1
48
- end
49
-
50
- it "*PROFILE* should render :profile page" do
51
- get 'profile'
52
- response.should render_template :profile
53
- end
54
-
55
- it "*PROFILE* should not to be redirect" do
56
- get 'profile'
57
- response.should_not be_redirect
58
- end
59
-
60
- it "*PROFILE* *current_user* helper should return user" do
61
- get 'profile'
62
- subject.current_user.should == @user
63
- end
64
- end
65
-
66
- end
@@ -1,6 +0,0 @@
1
- FactoryGirl.define do
2
- factory :page, class: Page do
3
- sequence(:title) { Faker::Lorem.sentence }
4
- sequence(:content) { Faker::Lorem.paragraphs(3).join }
5
- end
6
- end
@@ -1,55 +0,0 @@
1
- #############################################
2
- # EMPTY role
3
- #############################################
4
- FactoryGirl.define do
5
- factory :role_without_rules, class: Role do
6
- name 'user'
7
- title 'User role'
8
- description 'Default Role for users'
9
- end
10
- end
11
-
12
- #############################################
13
- # USER role
14
- #############################################
15
- role_user = {
16
- pages: {
17
- index: true,
18
- show: true,
19
- new: true,
20
- create: true,
21
- edit: true,
22
- update: true,
23
- destroy: true,
24
- my: true,
25
- secret: false
26
- }
27
- }
28
-
29
- FactoryGirl.define do
30
- factory :role_user, class: Role do
31
- name 'user'
32
- title 'User role'
33
- description 'Default Role for users'
34
- the_role role_user
35
- end
36
- end
37
-
38
- #############################################
39
- # MODERATOR role
40
- #############################################
41
-
42
- role_moderator = {
43
- moderator: {
44
- pages: true
45
- }
46
- }
47
-
48
- FactoryGirl.define do
49
- factory :role_moderator, class: Role do
50
- name 'pages_moderator'
51
- title 'Pages moderator'
52
- description 'Can do anything with pages'
53
- the_role role_moderator
54
- end
55
- end
@@ -1,11 +0,0 @@
1
- FactoryGirl.define do
2
- factory :user, class: User do
3
- sequence(:email) { Faker::Internet.email }
4
- sequence(:name) { Faker::Name.name }
5
- sequence(:company){ Faker::Company.name }
6
- sequence(:address){ Faker::Address.street_address }
7
-
8
- password 'qwerty'
9
- password_confirmation { |u| u.password }
10
- end
11
- end