Sha256: 7dc6789db23db8a6e65a73e974a19636a907d012b7270fb49ed13af82c65f7fa

Contents?: true

Size: 1.45 KB

Versions: 33

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module Quby
  describe AnswersController do
    include EngineControllerTesting

    let(:answer)        { double("Answer", id: '1') }
    let(:questionnaire) { double("Questionnaire", key: 'honos', renderer_version: :v1, errors: [], questions: []) }

    before do
      allow(Quby::Settings).to receive(:authorize_with_hmac).and_return(false)
      allow(Quby.answers).to receive(:find).with('honos', '1').and_return(answer)
      allow(Quby.questionnaires).to receive(:find).and_return(questionnaire)
    end

    it 'allows requests when they match session and url answer id' do
      session[:quby_answer_id] = '1'
      get :edit, questionnaire_id: 'honos', id: '1'
      expect(response).to render_template('v1/paged')
    end

    it 'disallows requests when they dont match with session' do
      session[:quby_answer_id] = '2'
      get :edit, questionnaire_id: 'honos', id: '1', return_url: '/returnurl', return_token: 'asdf'
      expect(response).to redirect_to('/returnurl?error=Quby%3A%3AInvalidAuthorizationError&key=asdf&return_from=quby&return_from_answer=1&status=error')
    end

    it 'disallows requests when they have no session' do
      get :edit, questionnaire_id: 'honos', id: '1', return_url: '/returnurl', return_token: 'asdf'
      expect(response).to redirect_to('/returnurl?error=Quby%3A%3AMissingAuthorizationError&key=asdf&return_from=quby&return_from_answer=1&status=error')
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
quby-5.6.5 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.6.3 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.6.2 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.6.1 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.6.0 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.5.0 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.4.0 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.3.1 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.3.0 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.2.0 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.1.3 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.1.2 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.1.1 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.1.0 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.0.5 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.0.4 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.0.3 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.0.2 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.0.1 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb
quby-5.0.0 spec/controllers/quby/answers_controller/authorize_with_id_from_session_spec.rb