Refactor SessionController#create, reduce complexity.

Don't compromise readablity
This commit is contained in:
railsaholic
2013-11-15 20:57:43 +05:30
parent 8a83f1a88f
commit 34bba737ff
6 changed files with 106 additions and 37 deletions

View File

@ -885,4 +885,25 @@ describe User do
end
describe "#find_email" do
let(:user) { Fabricate(:user, email: "bob@example.com") }
context "when email is exists in the email logs" do
before { user.stubs(:last_sent_email_address).returns("bob@lastemail.com") }
it "returns email from the logs" do
expect(user.find_email).to eq("bob@lastemail.com")
end
end
context "when email does not exist in the email logs" do
before { user.stubs(:last_sent_email_address).returns(nil) }
it "fetches the user's email" do
expect(user.find_email).to eq(user.email)
end
end
end
end