simple_roles 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -4
- data/README.md +7 -5
- data/Rakefile +0 -2
- data/lib/simple_roles/many/persistence.rb +0 -2
- data/lib/simple_roles/many/roles_methods.rb +0 -1
- data/lib/simple_roles/version.rb +1 -1
- data/simple_roles.gemspec +3 -4
- data/spec/simple_roles/many_spec.rb +19 -5
- metadata +4 -5
- data/VERSION +0 -1
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# CHANGELOG
|
2
2
|
|
3
|
-
|
3
|
+
## 0.0.9
|
4
4
|
|
5
|
-
|
5
|
+
### Changed
|
6
|
+
|
7
|
+
* Many strategy (persistence): setter `roles=` does not call save anymore, so it does not persist new records!
|
8
|
+
|
9
|
+
## 0.0.6
|
6
10
|
|
7
11
|
### Added
|
8
12
|
|
@@ -16,6 +20,6 @@
|
|
16
20
|
|
17
21
|
* Removed RolesArray presenter in "Many" strategy
|
18
22
|
|
19
|
-
|
23
|
+
## Prior to 0.0.6
|
20
24
|
|
21
25
|
Long-long history here undocumented...
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
SimpleRoles is a Rails Engine providing simple Role System for any Rails 3 app.
|
4
4
|
|
5
|
-
Initially
|
5
|
+
Initially it was created as demo role-system to accompany [CanTango gem](https://github.com/kristianmandrup/cantango) initial installiation and usage, and intended to be very easy to setup & use.
|
6
6
|
|
7
7
|
Now it is good to be used as a real role system inspite of or due to its almost maximum simplicity.
|
8
8
|
|
@@ -12,7 +12,10 @@ Now it is good to be used as a real role system inspite of or due to its almost
|
|
12
12
|
|
13
13
|
### Prerequisites
|
14
14
|
|
15
|
-
|
15
|
+
* Ruby 1.8.7 or 1.9.3
|
16
|
+
* Rails 3
|
17
|
+
* ActiveRecord with MySQL or SQLite
|
18
|
+
* ```User``` model in your Rails app.
|
16
19
|
|
17
20
|
### It is a Gem
|
18
21
|
|
@@ -24,7 +27,7 @@ gem 'simple_roles'
|
|
24
27
|
|
25
28
|
### Set up valid roles you're gonna have in your app and choose a Strategy.
|
26
29
|
|
27
|
-
Create file simple_roles.rb in config/initializers and write
|
30
|
+
Create file simple_roles.rb in config/initializers and write in it:
|
28
31
|
|
29
32
|
```ruby
|
30
33
|
# config/initializers/simple_roles.rb
|
@@ -47,7 +50,7 @@ end
|
|
47
50
|
Now it is time to choose beetween two strategies possible:
|
48
51
|
|
49
52
|
* One - each of your users has only one role. It is the most common
|
50
|
-
|
53
|
+
choice for the most of the apps.
|
51
54
|
* Many - your user can be _:editor_ and _:curator_ and _:instructor_ all
|
52
55
|
at the same time. More rare one, setup is slightly more complex.
|
53
56
|
|
@@ -61,7 +64,6 @@ class CreateUsers < ActiveRecord::Migration
|
|
61
64
|
create_table(:users) do |t|
|
62
65
|
# ...
|
63
66
|
t.string :role
|
64
|
-
# ...
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
data/Rakefile
CHANGED
data/lib/simple_roles/version.rb
CHANGED
data/simple_roles.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "simple_roles"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["stanislaw"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-02-22"
|
13
13
|
s.description = "Simple Role System for Rails Apps"
|
14
14
|
s.email = "s.pankevich@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
|
|
23
23
|
"MIT-LICENSE",
|
24
24
|
"README.md",
|
25
25
|
"Rakefile",
|
26
|
-
"VERSION",
|
27
26
|
"app/assets/images/simple_roles/.gitkeep",
|
28
27
|
"app/assets/javascripts/simple_roles/.gitkeep",
|
29
28
|
"app/assets/stylesheets/simple_roles/.gitkeep",
|
@@ -156,7 +155,7 @@ Gem::Specification.new do |s|
|
|
156
155
|
s.homepage = "http://github.com/stanislaw/simple_roles"
|
157
156
|
s.licenses = ["MIT"]
|
158
157
|
s.require_paths = ["lib"]
|
159
|
-
s.rubygems_version = "1.8.
|
158
|
+
s.rubygems_version = "1.8.24"
|
160
159
|
s.summary = "Rails Engine providing Role System for Rails apps"
|
161
160
|
|
162
161
|
if s.respond_to? :specification_version then
|
@@ -35,11 +35,11 @@ describe SimpleRoles::Many do
|
|
35
35
|
|
36
36
|
it "#has_role?, #has_roles?" do
|
37
37
|
subject.roles = [:admin]
|
38
|
-
|
38
|
+
|
39
39
|
subject.has_role?(:admin).should be_true
|
40
40
|
subject.has_role?(:admin, :user).should be_false
|
41
41
|
subject.has_roles?(:editor).should be_false
|
42
|
-
|
42
|
+
|
43
43
|
subject.roles = [ :admin, :user ]
|
44
44
|
|
45
45
|
subject.has_role?(:admin, :user).should be_true
|
@@ -75,15 +75,29 @@ describe SimpleRoles::Many do
|
|
75
75
|
subject.roles = ['user', 'editor']
|
76
76
|
subject.roles.should == Array.new([:user, :editor])
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
|
+
it "#roles= should not persist the user when being set" do
|
80
|
+
unsaved_user = build :user
|
81
|
+
unsaved_user.roles = [:admin]
|
82
|
+
unsaved_user.roles.should == [:admin]
|
83
|
+
unsaved_user.should_not be_persisted
|
84
|
+
end
|
85
|
+
|
86
|
+
it "#roles= should store the roles to be saved when user is persisted" do
|
87
|
+
unsaved_user = build :user
|
88
|
+
unsaved_user.roles = [:admin]
|
89
|
+
unsaved_user.save!
|
90
|
+
unsaved_user.reload.roles.should == [:admin]
|
91
|
+
end
|
92
|
+
|
79
93
|
it "#remove_roles should remove roles" do
|
80
94
|
subject.roles = [ :admin, :user, :editor ]
|
81
95
|
|
82
96
|
subject.roles.should == Array.new([:admin, :user, :editor])
|
83
|
-
|
97
|
+
|
84
98
|
subject.remove_roles :admin
|
85
99
|
subject.roles.should == Array.new([:user, :editor])
|
86
|
-
|
100
|
+
|
87
101
|
subject.remove_roles :admin, :user, :editor
|
88
102
|
subject.roles.should == Array.new([])
|
89
103
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_roles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: require_all
|
@@ -201,7 +201,6 @@ files:
|
|
201
201
|
- MIT-LICENSE
|
202
202
|
- README.md
|
203
203
|
- Rakefile
|
204
|
-
- VERSION
|
205
204
|
- app/assets/images/simple_roles/.gitkeep
|
206
205
|
- app/assets/javascripts/simple_roles/.gitkeep
|
207
206
|
- app/assets/stylesheets/simple_roles/.gitkeep
|
@@ -345,7 +344,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
345
344
|
version: '0'
|
346
345
|
segments:
|
347
346
|
- 0
|
348
|
-
hash: -
|
347
|
+
hash: -1674272083089527838
|
349
348
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
350
349
|
none: false
|
351
350
|
requirements:
|
@@ -354,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
354
353
|
version: '0'
|
355
354
|
requirements: []
|
356
355
|
rubyforge_project:
|
357
|
-
rubygems_version: 1.8.
|
356
|
+
rubygems_version: 1.8.24
|
358
357
|
signing_key:
|
359
358
|
specification_version: 3
|
360
359
|
summary: Rails Engine providing Role System for Rails apps
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.5
|