spec/castronaut/adapters/restful_authentication/user_spec.rb in relevance-castronaut-0.3.5 vs spec/castronaut/adapters/restful_authentication/user_spec.rb in relevance-castronaut-0.3.6

- old
+ new

@@ -21,9 +21,42 @@ Castronaut::Adapters::RestfulAuthentication::User.secure_digest('20293jr', ['j2049j'], '209f3jsf', '2ffndin0n') end end + describe "find by login" do + + it "attempts to the find the first user with the given login" do + Castronaut::Adapters::RestfulAuthentication::User.should_receive(:find).with(:first, :conditions => { :login => 'bob' }).and_return(nil) + Castronaut::Adapters::RestfulAuthentication::User.find_by_login('bob') + end + + it "returns nil if no user is found with the given login" do + Castronaut::Adapters::RestfulAuthentication::User.stub!(:find).and_return(nil) + Castronaut::Adapters::RestfulAuthentication::User.find_by_login('bob').should be_nil + end + + describe "when the config has extra authentication conditions" do + + before do + Castronaut.config.cas_adapter['extra_authentication_conditions'] = '1=2' + end + + it "has the extra_authentication_conditions key" do + Castronaut.config.cas_adapter.has_key?('extra_authentication_conditions').should be_true + Castronaut::Adapters::RestfulAuthentication::User.find_by_login('bob') + end + + it "attempts to find the user with the extra authentication conditions" do + Castronaut::Adapters::RestfulAuthentication::User.should_receive(:find).and_return(stub('user'), nil) + + Castronaut::Adapters::RestfulAuthentication::User.find_by_login('bob') + end + + end + + end + describe "authenticate" do it "attempts to find the user by the username / login" do Castronaut::Adapters::RestfulAuthentication::User.should_receive(:find_by_login).with('bob').and_return(nil) Castronaut::Adapters::RestfulAuthentication::User.authenticate('bob', '1234')