noodall-devise 0.1.6 → 0.1.7
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/app/models/user.rb +6 -0
- data/lib/noodall/devise/version.rb +1 -1
- data/spec/noodall_devise_spec.rb +17 -0
- data/spec/spec_helper.rb +4 -0
- metadata +3 -3
data/app/models/user.rb
CHANGED
@@ -30,6 +30,7 @@ class User
|
|
30
30
|
key :avatar_mime_type, String
|
31
31
|
#------------------------
|
32
32
|
|
33
|
+
cattr_accessor :editor_groups
|
33
34
|
|
34
35
|
def full_name
|
35
36
|
name || email
|
@@ -39,6 +40,11 @@ class User
|
|
39
40
|
tags.include?('admin')
|
40
41
|
end
|
41
42
|
|
43
|
+
def editor?
|
44
|
+
return true if self.class.editor_groups.blank?
|
45
|
+
(self.class.editor_groups & tags).size > 0
|
46
|
+
end
|
47
|
+
|
42
48
|
# Make emails for login case insensitive
|
43
49
|
def self.find_for_authentication(conditions)
|
44
50
|
conditions[:email] = /^#{conditions[:email].strip}$/i
|
data/spec/noodall_devise_spec.rb
CHANGED
@@ -4,4 +4,21 @@ describe Noodall::Devise do
|
|
4
4
|
it "should be valid" do
|
5
5
|
Noodall::Devise.should be_a(Module)
|
6
6
|
end
|
7
|
+
|
8
|
+
describe User do
|
9
|
+
it "should be an editor by default" do
|
10
|
+
u = Factory(:user)
|
11
|
+
u.editor?.should be(true)
|
12
|
+
end
|
13
|
+
it "should not be an editor if editor groups have been set" do
|
14
|
+
User.editor_groups = ['editor']
|
15
|
+
u = Factory(:user)
|
16
|
+
u.editor?.should be(false)
|
17
|
+
end
|
18
|
+
it "should be an editor if editor groups have been set and is in the correct group" do
|
19
|
+
User.editor_groups = ['editor']
|
20
|
+
u = Factory(:user, :group_list => 'editor')
|
21
|
+
u.editor?.should be(true)
|
22
|
+
end
|
23
|
+
end
|
7
24
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -18,6 +18,10 @@ Capybara.default_selector = :css
|
|
18
18
|
|
19
19
|
# Load support files
|
20
20
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
21
|
+
Factory.definition_file_paths = [
|
22
|
+
File.expand_path("../factories", __FILE__)
|
23
|
+
]
|
24
|
+
Factory.find_definitions
|
21
25
|
|
22
26
|
Rspec.configure do |config|
|
23
27
|
# Remove this line if you don't want Rspec's should and should_not
|
metadata
CHANGED