foodsoft/spec/support/api_oauth.rb

16 lines
575 B
Ruby
Raw Permalink Normal View History

2018-10-13 16:21:37 +02:00
# Dummy OAuth implementation with +current_user+ and scopes
module ApiOAuth
extend ActiveSupport::Concern
included do
let(:user) { build(:user) }
let(:api_scopes) { [] } # empty scopes for stricter testing (in reality this would be default_scopes)
let(:api_access_token) { double(acceptable?: true, accessible?: true, scopes: api_scopes) }
2018-10-13 16:21:37 +02:00
before { allow(controller).to receive(:doorkeeper_token) { api_access_token } }
2022-02-20 16:15:22 +01:00
2018-10-13 16:21:37 +02:00
before { allow(controller).to receive(:current_user) { user } }
let(:json_response) { JSON.parse(response.body) }
end
end