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.
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Noodall
2
2
  module Devise
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
@@ -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
@@ -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
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noodall-devise
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors: []
13
13