refinerycms-authentication 0.9.9.18 → 0.9.9.19

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.
@@ -2,10 +2,10 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{refinerycms-authentication}
5
- s.version = %q{0.9.9.18}
5
+ s.version = %q{0.9.9.19}
6
6
  s.summary = %q{Authentication engine for Refinery CMS}
7
7
  s.description = %q{The default authentication engine for Refinery CMS}
8
- s.date = %q{2011-04-16}
8
+ s.date = %q{2011-04-22}
9
9
  s.email = %q{info@refinerycms.com}
10
10
  s.homepage = %q{http://refinerycms.com}
11
11
  s.rubyforge_project = %q{refinerycms}
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.require_paths = %w(lib)
15
15
  s.executables = %w()
16
16
 
17
- s.add_dependency 'refinerycms-core', '= 0.9.9.18'
17
+ s.add_dependency 'refinerycms-core', '= 0.9.9.19'
18
18
  s.add_dependency 'devise', '~> 1.2.0'
19
19
 
20
20
  s.files = [
@@ -3,15 +3,17 @@ require 'spec_helper'
3
3
  Dir[File.expand_path('../../../features/support/factories.rb', __FILE__)].each {|f| require f}
4
4
 
5
5
  describe User do
6
+
7
+ let(:user) { Factory(:user) }
8
+ let(:refinery_user) { Factory(:refinery_user) }
9
+
6
10
  context "Roles" do
7
11
  context "add_role" do
8
12
  it "raises Exception when Role object is passed" do
9
- user = Factory(:user)
10
13
  lambda{ user.add_role(Role.new)}.should raise_exception
11
14
  end
12
15
 
13
16
  it "adds a Role to the User when role not yet assigned to User" do
14
- user = Factory(:user)
15
17
  lambda {
16
18
  user.add_role(:new_role)
17
19
  }.should change(user.roles, :count).by(1)
@@ -19,34 +21,30 @@ describe User do
19
21
  end
20
22
 
21
23
  it "does not add a Role to the User when this Role is already assigned to User" do
22
- user = Factory(:refinery_user)
23
24
  lambda {
24
- user.add_role(:refinery)
25
- }.should_not change(user.roles, :count).by(1)
26
- user.roles.collect(&:title).should include("Refinery")
25
+ refinery_user.add_role(:refinery)
26
+ }.should_not change(refinery_user.roles, :count).by(1)
27
+ refinery_user.roles.collect(&:title).should include("Refinery")
27
28
  end
28
29
  end
29
30
 
30
31
  context "has_role" do
31
32
  it "raises Exception when Role object is passed" do
32
- user = Factory(:user)
33
33
  lambda{ user.has_role?(Role.new)}.should raise_exception
34
34
  end
35
35
 
36
36
  it "returns the true if user has Role" do
37
- user = Factory(:refinery_user)
38
- user.has_role?(:refinery).should be_true
37
+ refinery_user.has_role?(:refinery).should be_true
39
38
  end
40
39
 
41
40
  it "returns false if user hasn't the Role" do
42
- user = Factory(:refinery_user)
43
- user.has_role?(:refinery_fail).should be_false
41
+ refinery_user.has_role?(:refinery_fail).should be_false
44
42
  end
45
43
  end
46
44
 
47
45
  describe "role association" do
48
46
  it "have a roles attribute" do
49
- Factory(:user).should respond_to(:roles)
47
+ user.should respond_to(:roles)
50
48
  end
51
49
  end
52
50
  end
@@ -54,8 +52,8 @@ describe User do
54
52
  context "validations" do
55
53
  # email and password validations are done by including devises validatable
56
54
  # module so those validations are not tested here
57
- before(:each) do
58
- @attr = {
55
+ let(:attr) do
56
+ {
59
57
  :username => "RefineryCMS",
60
58
  :email => "refinery@cms.com",
61
59
  :password => "123456",
@@ -63,61 +61,60 @@ describe User do
63
61
  }
64
62
  end
65
63
 
64
+
66
65
  it "requires username" do
67
- User.new(@attr.merge(:username => "")).should_not be_valid
66
+ User.new(attr.merge(:username => "")).should_not be_valid
68
67
  end
69
68
 
70
69
  it "rejects duplicate usernames" do
71
- User.create!(@attr)
72
- User.new(@attr.merge(:email => "another@email.com")).should_not be_valid
70
+ User.create!(attr)
71
+ User.new(attr.merge(:email => "another@email.com")).should_not be_valid
73
72
  end
74
73
  end
75
74
 
76
75
  describe ".find_for_database_authentication" do
77
76
  it "finds user either by username or email" do
78
- user = Factory(:user)
79
77
  User.find_for_database_authentication(:login => user.username).should == user
80
78
  User.find_for_database_authentication(:login => user.email).should == user
81
79
  end
82
80
  end
83
81
 
84
82
  describe "#can_delete?" do
85
- before(:each) do
86
- @user = Factory(:refinery_user)
87
- @user_not_persisted = Factory.build(:refinery_user)
88
- @super_user = Factory(:refinery_user)
89
- @super_user.add_role(:superuser)
83
+ let(:user_not_persisted) { Factory.build(:refinery_user) }
84
+ let(:super_user) do
85
+ super_user = Factory(:refinery_user)
86
+ super_user.add_role(:superuser)
87
+ super_user
90
88
  end
91
89
 
92
90
  context "won't allow to delete" do
93
91
  it "not persisted user record" do
94
- @user.can_delete?(@user_not_persisted).should be_false
92
+ refinery_user.can_delete?(user_not_persisted).should be_false
95
93
  end
96
94
 
97
95
  it "user with superuser role" do
98
- @user.can_delete?(@super_user).should be_false
96
+ refinery_user.can_delete?(super_user).should be_false
99
97
  end
100
98
 
101
99
  it "if user count with refinery role <= 1" do
102
- Role[:refinery].users.delete(@user)
103
- @super_user.can_delete?(@user).should be_false
100
+ Role[:refinery].users.delete(refinery_user)
101
+ super_user.can_delete?(refinery_user).should be_false
104
102
  end
105
103
 
106
104
  it "user himself" do
107
- @user.can_delete?(@user).should be_false
105
+ refinery_user.can_delete?(refinery_user).should be_false
108
106
  end
109
107
  end
110
108
 
111
109
  context "allow to delete" do
112
110
  it "if all conditions return true" do
113
- @super_user.can_delete?(@user).should be_true
111
+ super_user.can_delete?(refinery_user).should be_true
114
112
  end
115
113
  end
116
114
  end
117
115
 
118
116
  describe "#plugins=" do
119
117
  it "assigns plugins to user" do
120
- user = Factory(:user)
121
118
  plugin_list = ["refinery_one", "refinery_two", "refinery_three"]
122
119
  user.plugins = plugin_list
123
120
  user.plugins.collect { |p| p.name }.should == plugin_list
@@ -126,7 +123,6 @@ describe User do
126
123
 
127
124
  describe "#authorized_plugins" do
128
125
  it "returns array of user and always allowd plugins" do
129
- user = Factory(:user)
130
126
  ["refinery_one", "refinery_two", "refinery_three"].each_with_index do |name, index|
131
127
  user.plugins.create!(:name => name, :position => index)
132
128
  end
@@ -135,25 +131,23 @@ describe User do
135
131
  end
136
132
 
137
133
  describe "plugins association" do
138
- before(:each) do
139
- @user = Factory(:user)
140
- @plugin_list = ["refinery_one", "refinery_two", "refinery_three"]
141
- @user.plugins = @plugin_list
142
- end
134
+ let(:plugin_list) { ["refinery_one", "refinery_two", "refinery_three"] }
135
+ before { user.plugins = plugin_list }
143
136
 
144
137
  it "have a plugins attribute" do
145
- @user.should respond_to(:plugins)
138
+ user.should respond_to(:plugins)
146
139
  end
147
140
 
148
141
  it "returns plugins in ASC order" do
149
- @user.plugins[0].name.should == @plugin_list[0]
150
- @user.plugins[1].name.should == @plugin_list[1]
151
- @user.plugins[2].name.should == @plugin_list[2]
142
+ user.plugins[0].name.should == plugin_list[0]
143
+ user.plugins[1].name.should == plugin_list[1]
144
+ user.plugins[2].name.should == plugin_list[2]
152
145
  end
153
146
 
154
147
  it "deletes associated plugins" do
155
- @user.destroy
156
- UserPlugin.find_by_user_id(@user.id).should be_nil
148
+ user.destroy
149
+ UserPlugin.find_by_user_id(user.id).should be_nil
157
150
  end
158
151
  end
152
+
159
153
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: refinerycms-authentication
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.9.18
5
+ version: 0.9.9.19
6
6
  platform: ruby
7
7
  authors:
8
8
  - Resolve Digital
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-04-16 00:00:00 Z
16
+ date: 2011-04-22 00:00:00 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: refinerycms-core
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.9.18
26
+ version: 0.9.9.19
27
27
  type: :runtime
28
28
  version_requirements: *id001
29
29
  - !ruby/object:Gem::Dependency