mongoid-userstamps 3.1.3 → 3.2.1

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.
@@ -1,7 +1,6 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Admin
3
2
  include Mongoid::Document
4
3
  include Mongoid::Userstamp::User
5
4
 
6
5
  field :name
7
- end
6
+ end
@@ -1,9 +1,8 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Book
3
2
  include Mongoid::Document
4
3
  include Mongoid::Userstamp
5
4
 
6
- mongoid_userstamp user_model: 'User'
5
+ mongoid_userstamp user_model: "User"
7
6
 
8
7
  field :name
9
- end
8
+ end
@@ -1,11 +1,10 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Post
3
2
  include Mongoid::Document
4
3
  include Mongoid::Userstamp
5
4
 
6
- mongoid_userstamp user_model: 'Admin',
5
+ mongoid_userstamp user_model: "Admin",
7
6
  created_name: :writer,
8
7
  updated_name: :editor
9
8
 
10
9
  field :title
11
- end
10
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class User
3
2
  include Mongoid::Document
4
3
  include Mongoid::Userstamp::User
@@ -1,24 +1,21 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Mongoid::Userstamp::GemConfig do
5
-
6
4
  subject { Mongoid::Userstamp::GemConfig.new }
7
5
 
8
- describe '#initialize' do
9
-
10
- context 'without block' do
6
+ describe "#initialize" do
7
+ context "without block" do
11
8
  it { should be_a Mongoid::Userstamp::GemConfig }
12
9
  it { subject.created_name.should eq :created_by }
13
10
  it { subject.updated_name.should eq :updated_by }
14
11
  it { subject.user_reader.should eq :current_user }
15
12
  end
16
13
 
17
- context 'with block' do
14
+ context "with block" do
18
15
  subject do
19
16
  Mongoid::Userstamp::GemConfig.new do |u|
20
- u.created_name = :c_by
21
- u.updated_name = :u_by
17
+ u.created_name = :c_by
18
+ u.updated_name = :u_by
22
19
  u.user_reader = :foo
23
20
  end
24
21
  end
@@ -30,7 +27,7 @@ describe Mongoid::Userstamp::GemConfig do
30
27
  end
31
28
  end
32
29
 
33
- describe 'deprecated methods' do
30
+ describe "deprecated methods" do
34
31
  subject do
35
32
  Mongoid::Userstamp::GemConfig.new do |u|
36
33
  u.user_model = :bar
@@ -38,7 +35,7 @@ describe Mongoid::Userstamp::GemConfig do
38
35
  u.updated_column = :baz
39
36
  end
40
37
  end
41
- it { ->{ subject }.should_not raise_error }
38
+ it { -> { subject }.should_not raise_error }
42
39
  it { should be_a Mongoid::Userstamp::GemConfig }
43
40
  it { subject.created_name.should eq :bing }
44
41
  it { subject.updated_name.should eq :baz }
@@ -1,19 +1,20 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Mongoid::Userstamp::ModelConfig do
5
-
6
4
  subject { Mongoid::Userstamp::ModelConfig.new }
7
- before { Mongoid::Userstamp.stub('config').and_return(OpenStruct.new(created_name: :created_by,
8
- updated_name: :updated_by)) }
9
- before { Mongoid::Userstamp.stub('user_classes').and_return(['User']) }
10
-
11
- describe '#initialize' do
5
+ before do
6
+ Mongoid::Userstamp.stub("config").and_return(OpenStruct.new(created_name: :created_by,
7
+ updated_name: :updated_by))
8
+ end
9
+ before { Mongoid::Userstamp.stub("user_classes").and_return(["User"]) }
12
10
 
13
- context 'with opts hash' do
14
- subject { Mongoid::Userstamp::ModelConfig.new(user_model: :bar,
15
- created_name: :c_by,
16
- updated_name: :u_by) }
11
+ describe "#initialize" do
12
+ context "with opts hash" do
13
+ subject {
14
+ Mongoid::Userstamp::ModelConfig.new(user_model: :bar,
15
+ created_name: :c_by,
16
+ updated_name: :u_by)
17
+ }
17
18
 
18
19
  it { should be_a Mongoid::Userstamp::ModelConfig }
19
20
  it { subject.user_model.should eq :bar }
@@ -21,9 +22,9 @@ describe Mongoid::Userstamp::ModelConfig do
21
22
  it { subject.updated_name.should eq :u_by }
22
23
  end
23
24
 
24
- context 'without opts hash' do
25
+ context "without opts hash" do
25
26
  it { should be_a Mongoid::Userstamp::ModelConfig }
26
- it { subject.user_model.should eq 'User' }
27
+ it { subject.user_model.should eq "User" }
27
28
  it { subject.created_name.should eq :created_by }
28
29
  it { subject.updated_name.should eq :updated_by }
29
30
  end
@@ -1,17 +1,15 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Mongoid::Userstamp::Model do
4
+ subject(:book) { Book.new(name: "Crafting Rails Applications") }
5
+ subject(:post) { Post.new(title: "Understanding Rails") }
5
6
 
6
- subject(:book) { Book.new(name: 'Crafting Rails Applications') }
7
- subject(:post) { Post.new(title: 'Understanding Rails') }
7
+ let(:user_1) { User.create!(name: "Charles Dikkens") }
8
+ let(:user_2) { User.create!(name: "Edmund Wells") }
9
+ let(:admin_1) { Admin.create!(name: "JK Rowling") }
10
+ let(:admin_2) { Admin.create!(name: "Stephan Norway") }
8
11
 
9
- let(:user_1) { User.create!(name: 'Charles Dikkens') }
10
- let(:user_2) { User.create!(name: 'Edmund Wells') }
11
- let(:admin_1) { Admin.create!(name: 'JK Rowling') }
12
- let(:admin_2) { Admin.create!(name: 'Stephan Norway') }
13
-
14
- describe '::mongoid_userstamp_config' do
12
+ describe "::mongoid_userstamp_config" do
15
13
  before do
16
14
  @config = Book.instance_variable_get(:'@mongoid_userstamp_config')
17
15
  Book.instance_variable_set(:'@mongoid_userstamp_config', nil)
@@ -21,64 +19,71 @@ describe Mongoid::Userstamp::Model do
21
19
  Book.instance_variable_set(:'@mongoid_userstamp_config', @config)
22
20
  end
23
21
 
24
- context 'when options are not given' do
25
- subject{ Book.mongoid_userstamp_config }
22
+ context "when options are not given" do
23
+ subject { Book.mongoid_userstamp_config }
26
24
  it { should be_a Mongoid::Userstamp::ModelConfig }
27
25
  it { subject.user_model.should eq Admin }
28
26
  it { subject.created_name.should eq :created_by }
29
27
  it { subject.updated_name.should eq :updated_by }
30
28
  end
31
29
 
32
- context 'when options are given' do
33
- subject{ Book.mongoid_userstamp_config(user_model: 'User', created_name: :foo, updated_name: :bar) }
30
+ context "when options are given" do
31
+ subject { Book.mongoid_userstamp_config(user_model: "User", created_name: :foo, updated_name: :bar) }
34
32
  it { should be_a Mongoid::Userstamp::ModelConfig }
35
- it { subject.user_model.should eq 'User' }
33
+ it { subject.user_model.should eq "User" }
36
34
  it { subject.created_name.should eq :foo }
37
35
  it { subject.updated_name.should eq :bar }
38
36
  end
39
37
 
40
- context 'when mongoid_userstamp_user has been set' do
41
- subject{ Book.mongoid_userstamp_config; Book.mongoid_userstamp_config(user_model: 'User', created_name: :foo, updated_name: :bar) }
38
+ context "when mongoid_userstamp_user has been set" do
39
+ subject do
40
+ Book.mongoid_userstamp_config
41
+ Book.mongoid_userstamp_config(user_model: "User", created_name: :foo, updated_name: :bar)
42
+ end
42
43
  it { should be_a Mongoid::Userstamp::ModelConfig }
43
44
  it { subject.user_model.should eq Admin }
44
45
  it { subject.created_name.should eq :created_by }
45
46
  it { subject.updated_name.should eq :updated_by }
46
47
  end
47
48
 
48
- context 'when set via mongoid_userstamp method' do
49
- subject{ Book.mongoid_userstamp(user_model: 'User', created_name: :foo, updated_name: :bar); Book.mongoid_userstamp_config }
49
+ context "when set via mongoid_userstamp method" do
50
+ subject do
51
+ Book.mongoid_userstamp(user_model: "User", created_name: :foo, updated_name: :bar)
52
+ Book.mongoid_userstamp_config
53
+ end
50
54
  it { should be_a Mongoid::Userstamp::ModelConfig }
51
- it { subject.user_model.should eq 'User' }
55
+ it { subject.user_model.should eq "User" }
52
56
  it { subject.created_name.should eq :foo }
53
57
  it { subject.updated_name.should eq :bar }
54
58
  end
55
59
  end
56
60
 
57
- describe '::current_user' do
58
-
59
- before { Admin.current = nil; User.current = nil }
61
+ describe "::current_user" do
62
+ before do
63
+ Admin.current = nil
64
+ User.current = nil
65
+ end
60
66
 
61
- context 'when current book user is not set' do
67
+ context "when current book user is not set" do
62
68
  it { Book.current_user.should be_nil }
63
69
  it { Post.current_user.should be_nil }
64
70
  end
65
71
 
66
- context 'when current book user is set' do
67
- before{ User.current = user_1 }
72
+ context "when current book user is set" do
73
+ before { User.current = user_1 }
68
74
  it { Book.current_user.should eq user_1 }
69
75
  it { Post.current_user.should be_nil }
70
76
  end
71
77
 
72
- context 'when current post user is set' do
73
- before{ Admin.current = admin_1 }
78
+ context "when current post user is set" do
79
+ before { Admin.current = admin_1 }
74
80
  it { Book.current_user.should be_nil }
75
81
  it { Post.current_user.should eq admin_1 }
76
82
  end
77
83
  end
78
84
 
79
- describe 'relations and callbacks' do
80
-
81
- context 'when created without a user' do
85
+ describe "relations and callbacks" do
86
+ context "when created without a user" do
82
87
  before do
83
88
  User.current = nil
84
89
  Admin.current = nil
@@ -92,7 +97,7 @@ describe Mongoid::Userstamp::Model do
92
97
  it { post.editor.should be_nil }
93
98
  end
94
99
 
95
- context 'when created with a user' do
100
+ context "when created with a user" do
96
101
  before do
97
102
  User.current = user_1
98
103
  Admin.current = admin_1
@@ -106,7 +111,7 @@ describe Mongoid::Userstamp::Model do
106
111
  it { post.editor.should eq admin_1 }
107
112
  end
108
113
 
109
- context 'when creator is manually set' do
114
+ context "when creator is manually set" do
110
115
  before do
111
116
  User.current = user_1
112
117
  Admin.current = admin_1
@@ -122,7 +127,7 @@ describe Mongoid::Userstamp::Model do
122
127
  it { post.editor.should eq admin_1 }
123
128
  end
124
129
 
125
- context 'when updater is manually set' do
130
+ context "when updater is manually set" do
126
131
  before do
127
132
  User.current = user_1
128
133
  Admin.current = admin_1
@@ -138,7 +143,7 @@ describe Mongoid::Userstamp::Model do
138
143
  it { post.editor.should eq admin_2 }
139
144
  end
140
145
 
141
- context 'when user has been destroyed' do
146
+ context "when user has been destroyed" do
142
147
  before do
143
148
  User.current = user_1
144
149
  Admin.current = admin_1
@@ -154,4 +159,4 @@ describe Mongoid::Userstamp::Model do
154
159
  it { Post.first.editor.should be_nil }
155
160
  end
156
161
  end
157
- end
162
+ end
@@ -1,21 +1,18 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Mongoid::Userstamp::UserConfig do
5
-
6
4
  subject { Mongoid::Userstamp::UserConfig.new }
7
- before { Mongoid::Userstamp.stub('config').and_return(OpenStruct.new(user_reader: :foo)) }
8
-
9
- describe '#initialize' do
5
+ before { Mongoid::Userstamp.stub("config").and_return(OpenStruct.new(user_reader: :foo)) }
10
6
 
11
- context 'with opts hash' do
7
+ describe "#initialize" do
8
+ context "with opts hash" do
12
9
  subject { Mongoid::Userstamp::UserConfig.new({reader: :bar}) }
13
10
 
14
11
  it { should be_a Mongoid::Userstamp::UserConfig }
15
12
  it { subject.reader.should eq :bar }
16
13
  end
17
14
 
18
- context 'without opts hash' do
15
+ context "without opts hash" do
19
16
  it { should be_a Mongoid::Userstamp::UserConfig }
20
17
  it { subject.reader.should eq :foo }
21
18
  end
@@ -1,20 +1,21 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Mongoid::Userstamp::User do
4
+ subject(:book) { Book.new(name: "Crafting Rails Applications") }
5
+ subject(:post) { Post.new(title: "Understanding Rails") }
5
6
 
6
- subject(:book) { Book.new(name: 'Crafting Rails Applications') }
7
- subject(:post) { Post.new(title: 'Understanding Rails') }
7
+ let(:user_1) { User.create!(name: "Charles Dikkens") }
8
+ let(:user_2) { User.create!(name: "Edmund Wells") }
9
+ let(:admin_1) { Admin.create!(name: "JK Rowling") }
10
+ let(:admin_2) { Admin.create!(name: "Stephan Norway") }
8
11
 
9
- let(:user_1) { User.create!(name: 'Charles Dikkens') }
10
- let(:user_2) { User.create!(name: 'Edmund Wells') }
11
- let(:admin_1) { Admin.create!(name: 'JK Rowling') }
12
- let(:admin_2) { Admin.create!(name: 'Stephan Norway') }
13
-
14
- describe '::current and #current?' do
15
- before { Admin.current = nil; User.current = nil }
12
+ describe "::current and #current?" do
13
+ before do
14
+ Admin.current = nil
15
+ User.current = nil
16
+ end
16
17
 
17
- context 'when current users are not set' do
18
+ context "when current users are not set" do
18
19
  it { Admin.current.should be_nil }
19
20
  it { User.current.should be_nil }
20
21
  it { admin_1.current?.should be_falsey }
@@ -23,8 +24,8 @@ describe Mongoid::Userstamp::User do
23
24
  it { user_2.current?.should be_falsey }
24
25
  end
25
26
 
26
- context 'when current User is set' do
27
- before{ User.current = user_1 }
27
+ context "when current User is set" do
28
+ before { User.current = user_1 }
28
29
  it { User.current.should eq user_1 }
29
30
  it { Admin.current.should be_nil }
30
31
  it { admin_1.current?.should be_falsey }
@@ -33,8 +34,8 @@ describe Mongoid::Userstamp::User do
33
34
  it { user_2.current?.should be_falsey }
34
35
  end
35
36
 
36
- context 'when current Admin is set' do
37
- before{ Admin.current = admin_1 }
37
+ context "when current Admin is set" do
38
+ before { Admin.current = admin_1 }
38
39
  it { User.current.should be_nil }
39
40
  it { Admin.current.should eq admin_1 }
40
41
  it { admin_1.current?.should be_truthy }
@@ -44,8 +45,8 @@ describe Mongoid::Userstamp::User do
44
45
  end
45
46
  end
46
47
 
47
- describe '::do_as' do
48
- it 'should set the current user' do
48
+ describe "::do_as" do
49
+ it "should set the current user" do
49
50
  Admin.current = admin_1
50
51
  Admin.do_as admin_2 do
51
52
  Admin.current.should eq admin_2
@@ -53,13 +54,13 @@ describe Mongoid::Userstamp::User do
53
54
  Admin.current.should eq admin_1
54
55
  end
55
56
 
56
- it 'should return the value of the block' do
57
- Admin.do_as admin_2 do
58
- 'foo'
59
- end.should eq 'foo'
57
+ it "should return the value of the block" do
58
+ Admin.do_as admin_2 {
59
+ "foo"
60
+ }.should eq "foo"
60
61
  end
61
62
 
62
- it 'should revert user in case of error' do
63
+ it "should revert user in case of error" do
63
64
  Admin.current = admin_1
64
65
  begin
65
66
  Admin.do_as admin_2 do
@@ -71,25 +72,28 @@ describe Mongoid::Userstamp::User do
71
72
  end
72
73
  end
73
74
 
74
- describe '::mongoid_userstamp_user' do
75
- before{ User.instance_variable_set(:'@mongoid_userstamp_user', nil) }
75
+ describe "::mongoid_userstamp_user" do
76
+ before { User.instance_variable_set(:'@mongoid_userstamp_user', nil) }
76
77
 
77
- context 'when options are not given' do
78
- subject{ User.mongoid_userstamp_user }
78
+ context "when options are not given" do
79
+ subject { User.mongoid_userstamp_user }
79
80
  it { should be_a Mongoid::Userstamp::UserConfig }
80
- it { subject.reader.should eq :current_user }
81
+ it { subject.reader.should eq :current_user }
81
82
  end
82
83
 
83
- context 'when options are given' do
84
- subject{ User.mongoid_userstamp_user(reader: :foo) }
84
+ context "when options are given" do
85
+ subject { User.mongoid_userstamp_user(reader: :foo) }
85
86
  it { should be_a Mongoid::Userstamp::UserConfig }
86
- it { subject.reader.should eq :foo }
87
+ it { subject.reader.should eq :foo }
87
88
  end
88
89
 
89
- context 'when mongoid_userstamp_user has been set' do
90
- subject{ User.mongoid_userstamp_user; User.mongoid_userstamp_user(reader: :foo) }
90
+ context "when mongoid_userstamp_user has been set" do
91
+ subject do
92
+ User.mongoid_userstamp_user
93
+ User.mongoid_userstamp_user(reader: :foo)
94
+ end
91
95
  it { should be_a Mongoid::Userstamp::UserConfig }
92
- it { subject.reader.should eq :current_user }
96
+ it { subject.reader.should eq :current_user }
93
97
  end
94
98
  end
95
99
  end
@@ -1,27 +1,24 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Mongoid::Userstamp do
4
+ subject { Mongoid::Userstamp }
5
5
 
6
- subject{ Mongoid::Userstamp }
7
-
8
- let(:user_1){ User.create!(name: 'Edmund Wells') }
9
- let(:user_2){ User.create!(name: 'Charles Dikkens') }
10
- let(:admin_1){ Admin.create!(name: 'JK Rowling') }
11
-
12
- describe '#config' do
6
+ let(:user_1) { User.create!(name: "Edmund Wells") }
7
+ let(:user_2) { User.create!(name: "Charles Dikkens") }
8
+ let(:admin_1) { Admin.create!(name: "JK Rowling") }
13
9
 
10
+ describe "#config" do
14
11
  before { Mongoid::Userstamp.instance_variable_set(:'@config', nil) }
15
12
 
16
- context 'without block' do
17
- subject{ Mongoid::Userstamp.config }
13
+ context "without block" do
14
+ subject { Mongoid::Userstamp.config }
18
15
  it { should be_a Mongoid::Userstamp::GemConfig }
19
16
  it { subject.created_name.should eq :created_by }
20
17
  it { subject.updated_name.should eq :updated_by }
21
18
  it { subject.user_reader.should eq :current_user }
22
19
  end
23
20
 
24
- context 'with block' do
21
+ context "with block" do
25
22
  subject do
26
23
  Mongoid::Userstamp.config do |u|
27
24
  u.created_name = :c_by
@@ -35,87 +32,87 @@ describe Mongoid::Userstamp do
35
32
  it { subject.user_reader.should eq :foo }
36
33
  end
37
34
 
38
- context 'deprecated method' do
39
- subject{ Mongoid::Userstamp.configure }
35
+ context "deprecated method" do
36
+ subject { Mongoid::Userstamp.configure }
40
37
  it { should be_a Mongoid::Userstamp::GemConfig }
41
38
  end
42
39
  end
43
40
 
44
- describe '#current_user' do
41
+ describe "#current_user" do
45
42
  before do
46
43
  Mongoid::Userstamp.set_current_user(user_1)
47
44
  Mongoid::Userstamp.set_current_user(admin_1)
48
45
  end
49
- context 'when user_class is User' do
50
- subject{ Mongoid::Userstamp.current_user('User') }
51
- it{ should eq user_1 }
46
+ context "when user_class is User" do
47
+ subject { Mongoid::Userstamp.current_user("User") }
48
+ it { should eq user_1 }
52
49
  end
53
- context 'when user_class is Admin' do
54
- subject{ Mongoid::Userstamp.current_user('Admin') }
55
- it{ should eq admin_1 }
50
+ context "when user_class is Admin" do
51
+ subject { Mongoid::Userstamp.current_user("Admin") }
52
+ it { should eq admin_1 }
56
53
  end
57
- context 'when user_class is other' do
58
- subject{ Mongoid::Userstamp.current_user('foobar') }
59
- it{ should be_nil }
54
+ context "when user_class is other" do
55
+ subject { Mongoid::Userstamp.current_user("foobar") }
56
+ it { should be_nil }
60
57
  end
61
- context 'when user_class is not given' do
62
- subject{ Mongoid::Userstamp.current_user }
63
- it 'should use the default user_class' do
58
+ context "when user_class is not given" do
59
+ subject { Mongoid::Userstamp.current_user }
60
+ it "should use the default user_class" do
64
61
  should eq admin_1
65
62
  end
66
63
  end
67
64
  end
68
65
 
69
- describe '#model_classes' do
66
+ describe "#model_classes" do
70
67
  before { Mongoid::Userstamp.instance_variable_set(:'@model_classes', nil) }
71
- context 'default value' do
68
+ context "default value" do
72
69
  it { subject.model_classes.should eq [] }
73
70
  end
74
- context 'setting values' do
71
+ context "setting values" do
75
72
  before do
76
- subject.add_model_class 'Book'
77
- subject.add_model_class 'Post'
73
+ subject.add_model_class "Book"
74
+ subject.add_model_class "Post"
78
75
  end
79
76
  it { subject.model_classes.should eq [Book, Post] }
80
77
  end
81
78
  end
82
79
 
83
- describe '#user_classes' do
80
+ describe "#user_classes" do
84
81
  before { Mongoid::Userstamp.instance_variable_set(:'@user_classes', nil) }
85
- context 'default value' do
82
+ context "default value" do
86
83
  it { subject.user_classes.should eq [] }
87
84
  end
88
- context 'setting values' do
85
+ context "setting values" do
89
86
  before do
90
- subject.add_user_class 'Book'
91
- subject.add_user_class 'Post'
87
+ subject.add_user_class "Book"
88
+ subject.add_user_class "Post"
92
89
  end
93
90
  it { subject.user_classes.should eq [Book, Post] }
94
91
  end
95
92
  end
96
93
 
97
- describe '#store' do
98
- context 'when RequestStore is defined' do
94
+ describe "#store" do
95
+ context "when RequestStore is defined" do
99
96
  before do
100
- stub_const('RequestStore', Object.new)
101
- RequestStore.stub('store').and_return('foobar')
97
+ stub_const("RequestStore", Object.new)
98
+ RequestStore.stub("store").and_return("foobar")
102
99
  end
103
100
  it { subject.store.should eq RequestStore.store }
104
101
  end
105
- context 'when RequestStore is not defined' do
106
- before{ hide_const('RequestStore') }
102
+ context "when RequestStore is not defined" do
103
+ before { hide_const("RequestStore") }
107
104
  it { subject.store.should eq Thread.current }
108
105
  end
109
106
  end
110
107
 
111
- describe '#userstamp_key' do
112
- context 'when model is a Class' do
113
- subject{ Mongoid::Userstamp.userstamp_key(User) }
114
- it{ should eq :"mongoid_userstamp/user" }
115
- end
116
- context 'when model is a String' do
117
- subject{ Mongoid::Userstamp.userstamp_key('MyNamespace::User') }
118
- it{ should eq :"mongoid_userstamp/my_namespace/user" }
108
+ describe "#userstamp_key" do
109
+ context "when model is a Class" do
110
+ subject { Mongoid::Userstamp.userstamp_key(User) }
111
+ it { should eq :"mongoid_userstamp/user" }
112
+ end
113
+ context "when model is a String" do
114
+ subject { Mongoid::Userstamp.userstamp_key("MyNamespace::User") }
115
+ it { should eq :"mongoid_userstamp/my_namespace/user" }
119
116
  end
120
117
  end
121
118
  end