Sha256: 5f196b840d9839471164fc880bd6f410569dc228ceac0f8a40dd466910bb9c03

Contents?: true

Size: 1.52 KB

Versions: 6

Compression:

Stored size: 1.52 KB

Contents

require 'rails_helper'

module MnoEnterprise
  describe PagesController, type: :controller do
    render_views
    routes { MnoEnterprise::Engine.routes }

    # Freeze time (JWT are time dependent)
    before { Timecop.freeze }
    after { Timecop.return }

    let(:user) { build(:user) }
    let(:app_instance) { build(:app_instance) }

    before do
      api_stub_for(get: "/users/#{user.id}", response: from_api(user))
      api_stub_for(put: "/users/#{user.id}", response: from_api(user))
      api_stub_for(get: "/app_instances", response: from_api([app_instance]))
    end

    describe 'GET #launch' do
      let(:app_instance) { build(:app_instance) }
      before { sign_in user }
      subject { get :launch, id: app_instance.uid }

      it_behaves_like "a navigatable protected user action"

      it 'redirect to the mno enterprise launch page with a web token' do
        subject
        expect(response).to redirect_to(MnoEnterprise.router.launch_url(app_instance.uid, wtk: MnoEnterprise.jwt({user_id: user.uid})))
      end
    end

    describe 'GET #app_access_unauthorized' do
      subject { get :app_access_unauthorized }
      before { subject }
      it { expect(response).to be_success }
    end

    describe 'GET #billing_details_required' do
      subject { get :billing_details_required }
      before { subject }
      it { expect(response).to be_success }
    end

    describe 'GET #app_logout' do
      subject { get :app_logout }
      before { subject }
      it { expect(response).to be_success }
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mno-enterprise-api-3.1.4 spec/controllers/mno_enterprise/pages_controller_spec.rb
mno-enterprise-api-3.0.7 spec/controllers/mno_enterprise/pages_controller_spec.rb
mno-enterprise-api-3.1.3 spec/controllers/mno_enterprise/pages_controller_spec.rb
mno-enterprise-api-3.0.6 spec/controllers/mno_enterprise/pages_controller_spec.rb
mno-enterprise-api-3.1.2 spec/controllers/mno_enterprise/pages_controller_spec.rb
mno-enterprise-api-3.0.5 spec/controllers/mno_enterprise/pages_controller_spec.rb