# Failing spec: sign\_in(Fabricate(:user))

**URL:** <https://meta.discourse.org/t/failing-spec-sign-in-fabricate-user/146158>\
**Category:** Development\
**Created:** [30 maart 2020 om 16:33 UTC](https://meta.discourse.org/t/failing-spec-sign-in-fabricate-user/146158 "2020-03-30T16:33:14Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [23 augustus 2021 om 07:41 UTC](https://meta.discourse.org/t/failing-spec-sign-in-fabricate-user/146158/6 "2021-08-23T07:41:34Z")

</div>

I’m having an issue with the `sign_in` helper function, any help very much appreciated! 🤯 :

> <https://github.com/discourse/discourse/blob/f1701764a68f9f5d5c785579001005eccda8b19a/spec/support/integration_helpers.rb#L28>

When used in this test, it doesn’t seem to deliver a current\_user and fails with a 403 (instead of a 200)

> <https://github.com/discourse/discourse-follow/blob/8920cd30b7f07c7a4cb99ac5e98405fead8daa66/spec/requests/follow_controller_spec.rb#L33>

I’m running the test like so to isolate it, but it doesn’t work either way:

`LOAD_PLUGINS=1 RAILS_ENV=test rspec plugins/discourse-follow/spec/requests/follow_controller_spec.rb:32`

If I add a `byebug` in the corresponding controller and check for current\_user it is nil (hence the `403` I guess!):

> <https://github.com/discourse/discourse-follow/blob/8920cd30b7f07c7a4cb99ac5e98405fead8daa66/app/controllers/follow/follow_controller.rb#L9>

```plaintext
Randomized with seed 50945

[5, 14] in /home/merefield/code/discourse-follow/app/controllers/follow/follow_controller.rb
    5: def update
    6: params.require(:username)
    7: params.require(:follow)
    8: byebug
    9:
=> 10: raise Discourse::InvalidAccess.new unless current_user
   11: raise Discourse::InvalidParameters.new if current_user.username == params[:username]
   12:
   13: if user = User.find_by(username: params[:username])
   14: updater = Follow::Updater.new(current_user, user)
(byebug) current_user
nil

```

---

_[View the full topic](https://meta.discourse.org/t/failing-spec-sign-in-fabricate-user/146158)._
