logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

authorizations_controller_spec.rb (1296B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Oauth::AuthorizationsController, type: :controller do
  4. render_views
  5. let(:app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: 'http://localhost/') }
  6. describe 'GET #new' do
  7. subject do
  8. get :new, params: { client_id: app.uid, response_type: 'code', redirect_uri: 'http://localhost/' }
  9. end
  10. shared_examples 'stores location for user' do
  11. it 'stores location for user' do
  12. subject
  13. expect(controller.stored_location_for(:user)).to eq "/oauth/authorize?client_id=#{app.uid}&redirect_uri=http%3A%2F%2Flocalhost%2F&response_type=code"
  14. end
  15. end
  16. context 'when signed in' do
  17. before do
  18. sign_in Fabricate(:user), scope: :user
  19. end
  20. it 'returns http success' do
  21. subject
  22. expect(response).to have_http_status(:success)
  23. end
  24. it 'gives options to authorize and deny' do
  25. subject
  26. expect(response.body).to match(/Authorize/)
  27. end
  28. include_examples 'stores location for user'
  29. end
  30. context 'when not signed in' do
  31. it 'redirects' do
  32. subject
  33. expect(response).to redirect_to '/auth/sign_in'
  34. end
  35. include_examples 'stores location for user'
  36. end
  37. end
  38. end