Sha256: 17e4571200bf00eb877f1a34d3eee09b948eb08b62ccf925f4cfe38b324cbf25

Contents?: true

Size: 1.18 KB

Versions: 14

Compression:

Stored size: 1.18 KB

Contents

require 'rails_helper'

class DummyBaseController < PgEngine::BaseController
  def action_with_redirect
    raise PgEngine::BaseController::Redirect, '/some_path'
  end

  def check_dev_user
    @dev_user_or_env = dev_user_or_env?
    @dev_user = dev_user?
    head :ok
  end
end

# rubocop:disable RSpec/MultipleExpectations
# rubocop:disable RSpec/FilePath
# rubocop:disable RSpec/SpecFilePathFormat
describe DummyBaseController do
  describe 'PgEngine::BaseController::Redirect' do
    before { get :action_with_redirect }

    it do
      expect(response).to redirect_to '/some_path'
    end
  end

  describe '#dev_user_or_env?' do
    let(:user) { create :user, :developer }

    before do
      sign_in user if user.present?
      get :check_dev_user
    end

    it do
      expect(assigns(:dev_user_or_env)).to be_truthy
      expect(assigns(:dev_user)).to be_truthy
    end

    context 'when not signed in' do
      let(:user) { nil }

      it do
        expect(assigns(:dev_user_or_env)).to be_falsey
        expect(assigns(:dev_user)).to be_falsey
      end
    end
  end
end
# rubocop:enable RSpec/MultipleExpectations
# rubocop:enable RSpec/FilePath
# rubocop:enable RSpec/SpecFilePathFormat

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha.38 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.37 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.36 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.35 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.34 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.33 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.32 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.31 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.30 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.29 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.28 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.27 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.26 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
pg_rails-7.0.8.pre.alpha.25 pg_engine/spec/controllers/pg_engine/base_controller_spec.rb