Skip to content

Commit

Permalink
FindUserByResetToken green specs
Browse files Browse the repository at this point in the history
  • Loading branch information
npauzenga committed Jan 12, 2016
1 parent cf5755f commit 7ead975
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions app/interactors/find_user_by_reset_token.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
class FindUserByResetToken
include Interactor

class FindUserByResetToken < StandardInteraction
def validate_input
context.fail!(errors: "invalid input") unless context.reset_token
end

def execute
context.user = User.find_by(reset_digest: digest_token)
end

def validate_output
context.fail!(errors: "invalid output") unless context.user
end

private

def digest_token
Encryptor.digest_token(context.reset_token)
end
end
4 changes: 2 additions & 2 deletions spec/interactors/find_user_by_reset_token_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

context "when successful" do
before do
create(:confirmed_user, reset_digest: token[0])
@user = create(:confirmed_user, reset_digest: token[0])
end

subject do
Expand All @@ -16,7 +16,7 @@
end

it "find the user" do
expect(subject.user).to eq(user)
expect(subject.user).to eq(@user)
end
end

Expand Down

0 comments on commit 7ead975

Please sign in to comment.