Sha256: eac8170828f64530f7ce0d61486b4681d4982a818cdfa783314b1a4149419970

Contents?: true

Size: 1.88 KB

Versions: 20

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe Alchemy::BaseController do

	describe "#set_language_from" do

		it "should set the language from id" do
			@language = Alchemy::Language.get_default
			controller.send :set_language_from, @language.id
			controller.session[:language_id].should == @language.id
		end

		it "should set the language from code" do
			@language = Factory(:language, :code => 'kl')
			controller.send :set_language_from, "kl"
			controller.session[:language_id].should == @language.id
			controller.session[:language_code].should == @language.code
		end

		it "should set the language from id as string" do
			@language = Factory(:language)
			controller.send :set_language_from, @language.id.to_s
			controller.session[:language_id].should == @language.id
			controller.session[:language_code].should == @language.code
		end

	end

	describe "#set_language" do

		context "with no lang param" do

			it "should set the default language" do
				controller.stub!(:params).and_return({})
				controller.send :set_language
				controller.session[:language_id].should == Alchemy::Language.get_default.id
				controller.session[:language_code].should == Alchemy::Language.get_default.code
			end

		end

		context "with lang param" do

			it "should set the language" do
				@language = Factory(:language)
				controller.stub!(:params).and_return({:lang => 'kl'})
				controller.send :set_language
				controller.session[:language_id].should == @language.id
				controller.session[:language_code].should == @language.code
			end

			context "for language that does not exist" do

				it "should set the language to default" do
					controller.stub!(:params).and_return({:lang => 'fo'})
					controller.send :set_language
					controller.session[:language_id].should == Alchemy::Language.get_default.id
					controller.session[:language_code].should == Alchemy::Language.get_default.code
				end

			end

		end

	end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
alchemy_cms-2.1.12 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.11 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.9.1 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.9 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.8.1 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.8 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.7 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.6 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.5 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.4 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.3 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.2 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.1 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.rc6 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.rc5 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.rc4 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.rc3 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.rc2 spec/controllers/base_controller_spec.rb
alchemy_cms-2.1.beta6 spec/controllers/base_controller_spec.rb