royce 1.0.4 → 1.0.5
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/lib/royce/macros.rb +4 -2
- data/lib/royce/methods.rb +9 -1
- data/lib/royce/version.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +110812 -0
- data/test/dummy/log/test.log +63569 -240
- data/test/roller_test.rb +20 -0
- data/test/scopes_test.rb +8 -3
- metadata +6 -2
data/test/roller_test.rb
CHANGED
@@ -96,6 +96,16 @@ describe "Basic tests" do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
it 'Has bang methods to assign a role' do
|
100
|
+
user.has_role?(:admin).must_equal false
|
101
|
+
user.admin!
|
102
|
+
user.has_role?(:admin).must_equal true
|
103
|
+
|
104
|
+
user.has_role?(:editor).must_equal false
|
105
|
+
user.editor!
|
106
|
+
user.has_role?(:editor).must_equal true
|
107
|
+
end
|
108
|
+
|
99
109
|
it "knows allowed roles" do
|
100
110
|
User.available_roles.each do |role|
|
101
111
|
user.allowed_role?(role).must_equal true
|
@@ -108,6 +118,16 @@ describe "Basic tests" do
|
|
108
118
|
end
|
109
119
|
end
|
110
120
|
|
121
|
+
it "has a list of roles" do
|
122
|
+
user.role_list.must_equal []
|
123
|
+
|
124
|
+
user.add_role :user
|
125
|
+
user.role_list.must_equal ['user']
|
126
|
+
|
127
|
+
user.add_role :admin
|
128
|
+
user.role_list.must_equal ['user', 'admin']
|
129
|
+
end
|
130
|
+
|
111
131
|
|
112
132
|
end
|
113
133
|
|
data/test/scopes_test.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
4
|
+
ActiveRecord::Migration.verbose = false
|
4
5
|
ActiveRecord::Migration.create_table :employees
|
5
6
|
ActiveRecord::Migration.create_table :baby_boomers
|
6
7
|
load "dummy/db/schema.rb"
|
7
8
|
ActiveRecord::Migrator.up "db/migrate"
|
8
9
|
|
9
10
|
def human_roles
|
10
|
-
|
11
|
+
%i( partier rocker )
|
12
|
+
end
|
13
|
+
|
14
|
+
def human_roles_strings
|
15
|
+
human_roles.map(&:to_s)
|
11
16
|
end
|
12
17
|
|
13
18
|
class Employee < ActiveRecord::Base
|
14
|
-
royce_roles
|
19
|
+
royce_roles human_roles_strings
|
15
20
|
end
|
16
21
|
|
17
22
|
class BabyBoomer < ActiveRecord::Base
|
@@ -27,7 +32,7 @@ describe "Testing class-level scopes" do
|
|
27
32
|
end
|
28
33
|
|
29
34
|
it "Has named scopes" do
|
30
|
-
Employee.available_role_names.must_equal
|
35
|
+
Employee.available_role_names.must_equal human_roles_strings
|
31
36
|
end
|
32
37
|
|
33
38
|
it "Owner named scopes return owners with role" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: royce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Nash
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -143,11 +143,13 @@ files:
|
|
143
143
|
- test/dummy/config/locales/en.yml
|
144
144
|
- test/dummy/config/routes.rb
|
145
145
|
- test/dummy/config/secrets.yml
|
146
|
+
- test/dummy/db/development.sqlite3
|
146
147
|
- test/dummy/db/migrate/20140817214831_create_users.rb
|
147
148
|
- test/dummy/db/migrate/20140821050450_create_royce.rb
|
148
149
|
- test/dummy/db/schema.rb
|
149
150
|
- test/dummy/db/seeds.rb
|
150
151
|
- test/dummy/db/test.sqlite3
|
152
|
+
- test/dummy/log/development.log
|
151
153
|
- test/dummy/log/test.log
|
152
154
|
- test/dummy/public/404.html
|
153
155
|
- test/dummy/public/422.html
|
@@ -210,11 +212,13 @@ test_files:
|
|
210
212
|
- test/dummy/config/routes.rb
|
211
213
|
- test/dummy/config/secrets.yml
|
212
214
|
- test/dummy/config.ru
|
215
|
+
- test/dummy/db/development.sqlite3
|
213
216
|
- test/dummy/db/migrate/20140817214831_create_users.rb
|
214
217
|
- test/dummy/db/migrate/20140821050450_create_royce.rb
|
215
218
|
- test/dummy/db/schema.rb
|
216
219
|
- test/dummy/db/seeds.rb
|
217
220
|
- test/dummy/db/test.sqlite3
|
221
|
+
- test/dummy/log/development.log
|
218
222
|
- test/dummy/log/test.log
|
219
223
|
- test/dummy/public/404.html
|
220
224
|
- test/dummy/public/422.html
|