Sha256: 0881c2be6d189c16b840811bbd6afbb2c5141d623364739fa3d5c506719bf006

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

require 'rails_helper'

module RocketJobMissionControl
  RSpec.describe ApplicationController, type: :controller do
    controller do
      def index
        @time_zone = Time.zone

        render text: 'Time Zoned'
      end
    end

    describe "#with_time_zone" do
      let(:session_params) { {} }
      let(:expected_time_zone) { 'UTC' }

      before do
        get :index, {}, session_params
      end

      context "with a session present" do
        context "that contains a time zone" do
          let(:expected_time_zone) { 'America/Los_Angeles' }
          let(:session_params) { {'time_zone' => expected_time_zone} }

          it "sets the time zone correctly" do
            expect(assigns(:time_zone).name).to eq(expected_time_zone)
          end
        end

        context 'that does not contain a time zone' do
          let(:session_params) { {'user_id' => '42'} }

          it 'sets the time zone correctly' do
            expect(assigns(:time_zone).name).to eq(expected_time_zone)
          end
        end
      end

      context "with no session present" do
        it "sets the time zone correctly" do
          expect(assigns(:time_zone).name).to eq(expected_time_zone)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rocketjob_mission_control-3.0.0.rc1 spec/controllers/application_controller_spec.rb
rocketjob_mission_control-2.1.1 spec/controllers/application_controller_spec.rb
rocketjob_mission_control-2.1.0 spec/controllers/application_controller_spec.rb
rocketjob_mission_control-2.0.0 spec/controllers/application_controller_spec.rb
rocketjob_mission_control-2.0.0.rc2 spec/controllers/application_controller_spec.rb
rocketjob_mission_control-2.0.0.rc1 spec/controllers/application_controller_spec.rb