/
user_spec.rb
61 lines (47 loc) · 1.59 KB
/
user_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/../app/mailers/sorcery_mailer')
require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/user_shared_examples')
describe "User with no submodules (core)" do
before(:all) do
sorcery_reload!
end
describe User, "when app has plugin loaded" do
it "User should respond_to .authenticates_with_sorcery!" do
User.should respond_to(:authenticates_with_sorcery!)
end
end
# ----------------- PLUGIN CONFIGURATION -----------------------
it_should_behave_like "rails_3_core_model"
describe User, "external users" do
it_should_behave_like "external_user"
end
describe User, "when inherited" do
it "should inherit mongoid fields" do
User.class_eval do
field :blabla
end
class SubUser < User
end
SubUser.fields.should include("blabla")
end
end
describe User, "mongoid adapter" do
before(:each) do
create_new_user
@user = User.first
end
after(:each) do
User.delete_all
end
it "find_by_username should work as expected" do
User.find_by_username("gizmo").should == @user
end
it "find_by_username should work as expected with multiple username attributes" do
sorcery_model_property_set(:username_attribute_names, [:username, :email])
User.find_by_username("gizmo").should == @user
end
it "find_by_email should work as expected" do
User.find_by_username("bla@bla.com").should == @user
end
end
end