simple_roles 0.0.8 → 0.0.9

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.
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.8.7
3
4
  - 1.9.3
4
5
  script: "rake"
5
6
  gemfile:
data/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
- # master
1
+ # CHANGELOG
2
2
 
3
- ...
3
+ ## 0.0.9
4
4
 
5
- # Version 0.0.6
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
- # Versions <= 0.0.5
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, 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.
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
- SimpleRoles requires you have have User model in your Rails app. That's all.
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 there:
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
- choise for the most of the apps.
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
@@ -42,8 +42,6 @@ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
42
42
 
43
43
  load 'rails/tasks/engine.rake'
44
44
 
45
- Bundler::GemHelper.install_tasks
46
-
47
45
  require 'rspec/core'
48
46
  require 'rspec/core/rake_task'
49
47
  RSpec::Core::RakeTask.new(:spec) do |spec|
@@ -18,8 +18,6 @@ module SimpleRoles
18
18
  rolez.to_symbols!.flatten!
19
19
 
20
20
  super retrieve_roles(rolez)
21
-
22
- save!
23
21
  end
24
22
 
25
23
  private
@@ -52,7 +52,6 @@ module SimpleRoles
52
52
  def has_roles? *rolez
53
53
  rolez.flatten!
54
54
 
55
- # rrr roles
56
55
  rolez.all? do |role|
57
56
  roles.include? role
58
57
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleRoles
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
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"
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 = "2012-06-28"
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.19"
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.8
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: 2012-06-28 00:00:00.000000000 Z
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: -339353645
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.19
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