Skip to content

Commit

Permalink
Move remember token test to model specs
Browse files Browse the repository at this point in the history
The controller spec shouldn't know anything about regenerating the remember
token, so the test should be moved over to the User model spec instead.
  • Loading branch information
mxie committed Jul 17, 2015
1 parent 7187d3e commit 7f3ff29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 1 addition & 11 deletions spec/controllers/passwords_controller_spec.rb
Expand Up @@ -101,16 +101,6 @@
expect(user.reload.encrypted_password).not_to eq old_encrypted_password
end

it "sets the remember token and clears the confirmation token" do
user = create(:user, :with_forgotten_password)

put :update, update_parameters(user, new_password: "my_new_password")

user.reload
expect(user.remember_token).not_to be_nil
expect(user.confirmation_token).to be_nil
end

it "signs the user in and redirects" do
user = create(:user, :with_forgotten_password)

Expand All @@ -121,7 +111,7 @@
end
end

context "no password provided" do
context "password update fails" do
it "does not update the password" do
user = create(:user, :with_forgotten_password)
old_encrypted_password = user.encrypted_password
Expand Down
9 changes: 9 additions & 0 deletions spec/user_spec.rb
Expand Up @@ -85,6 +85,15 @@

expect(user.confirmation_token).to be_nil
end

it "sets the remember token" do
user = create(:user, :with_forgotten_password)

user.update_password("my_new_password")

user.reload
expect(user.remember_token).not_to be_nil
end
end

context "with blank password" do
Expand Down

0 comments on commit 7f3ff29

Please sign in to comment.