Sha256: df4047044f1fd6c4dd3c8448d3a38a4cbb78558f2413bea7493d4b5513244b86

Contents?: true

Size: 999 Bytes

Versions: 9

Compression:

Stored size: 999 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe Lcms::Engine::WelcomeController do
  #
  # In the Host application should be a proxy which will redirect
  # request inside mounted engine
  #
  describe 'GET oauth2callback' do
    let(:code) { Faker::Lorem.words.join }

    before { request.env['HTTP_REFERER'] = Lcms::Engine::WelcomeController::OAUTH_REFERER }

    subject { get :oauth2callback, params: { code: code } }

    it 'skips authorization' do
      subject
      expect(response).to be_successful
    end

    it 'renders passed in params as JSON' do
      subject
      result = JSON.parse(response.body)
      expect(result['text']).to eq Lcms::Engine::WelcomeController::OAUTH_MESSAGE
      expect(result['code']).to eq code
    end

    context 'when referer is not a Google service' do
      before { request.env['HTTP_REFERER'] = 'test.com' }

      it 'returns 404' do
        subject
        expect(response).to have_http_status(404)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 spec/controllers/welcome_controller_spec.rb
lcms-engine-0.5.4 spec/controllers/welcome_controller_spec.rb
lcms-engine-0.5.3 spec/controllers/welcome_controller_spec.rb
lcms-engine-0.5.2 spec/controllers/welcome_controller_spec.rb
lcms-engine-0.5.1 spec/controllers/welcome_controller_spec.rb
lcms-engine-0.5.0 spec/controllers/welcome_controller_spec.rb
lcms-engine-0.4.2 spec/controllers/welcome_controller_spec.rb
lcms-engine-0.4.1 spec/controllers/welcome_controller_spec.rb
lcms-engine-0.4.0 spec/controllers/welcome_controller_spec.rb