Sha256: 1267c6c28bf28d6ecda1c94c9592275f0b4378b1c7979478b77371257679a8e0

Contents?: true

Size: 1018 Bytes

Versions: 3

Compression:

Stored size: 1018 Bytes

Contents

require 'spec_helper'

describe RailsLocaleDetection::ControllerMethods do
  let(:request) { MockRequest.new }
  subject(:controller) { MockController.new(request) }

  it 'provides a blank user locale method' do
    expect(controller.user_locale).to be_nil
  end

  it 'should provide a detect locale method' do
    expect(controller.class).to respond_to(:detect_locale)
  end

  context 'when the rails is 4.0 or later' do
    before do
      skip "Rails version is #{::Rails.version.to_s}" unless ::Rails.version.to_s >= '4.0'
    end

    it 'adds the detector as a before action' do
      expect(controller.class.before_actions).to eq([[RailsLocaleDetection::LocaleDetector]])
    end
  end

  context 'when the rails is less than 4.0' do
    before do
      skip "Rails version is #{::Rails.version.to_s}" unless ::Rails.version.to_s < '4.0'
    end

    it 'adds the detector as a before filter' do
      expect(controller.class.before_filters).to eq([[RailsLocaleDetection::LocaleDetector]])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_locale_detection-2.3.0 spec/rails_locale_detection/controller_methods_spec.rb
rails_locale_detection-2.2.0 spec/rails_locale_detection/controller_methods_spec.rb
rails_locale_detection-2.1.0 spec/rails_locale_detection/controller_methods_spec.rb