Sha256: c2c33806b554973fa7c2a6e5a9915a6cadf7e77c232de860796c41d3c67c378d

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe Adminpanel::Section do
	before do
		@section = Adminpanel::Section.new(
			:name => "Section name",
			:description => "Test description for index",
			:has_image => true,
			:key => "example_key",
			:has_description => true,
			:page => "index"
		)
	end

	subject { @section }

	it { should respond_to(:description) }
	it { should respond_to(:has_image) }	
	it { should respond_to(:key) }
	it { should respond_to(:name) }
	it { should respond_to(:has_description) }	
	it { should respond_to(:page) }	

	describe "when key is telephone and has less than 10 chars" do
		before do 
			@section.key = "telephone"
			@section.description = "1" * 9
		end
		it { @section.valid? eq false}
	end	

	describe "when key is telephone and has more than 10 chars" do
		before do 
			@section.key = "telephone"
			@section.description = "1" * 11
		end
		it { @section.valid? eq false}
	end	

	describe "when key is telephone and has 10 chars" do
		before do
			@section.key = "telephone"
			@section.description = "1" * 10
		end
		it { @section.valid? eq true}

	end	

	describe "when key is blank" do
		before {@section.key = " "}
		it { @section.valid? eq false}
	end	

	describe "when name is blank" do
		before {@section.name = " "}
		it { @section.valid? eq false}
	end	

	describe "when description is blank" do
		before {@section.description = " "}
		it { @section.valid? eq false}
	end

	describe "default scope" do
		it { expect(Adminpanel::Section.scoped.to_sql).to eq Adminpanel::Section.reorder('').order('page ASC').to_sql}
	end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
adminpanel-1.2.9 spec/models/section_spec.rb
adminpanel-1.2.8 spec/models/section_spec.rb
adminpanel-1.2.7 spec/models/section_spec.rb
adminpanel-1.2.6 spec/models/section_spec.rb
adminpanel-1.2.5 spec/models/section_spec.rb
adminpanel-1.2.4 spec/models/section_spec.rb
adminpanel-1.2.3 spec/models/section_spec.rb
adminpanel-1.2.2 spec/models/section_spec.rb
adminpanel-1.2.1 spec/models/section_spec.rb
adminpanel-1.2.0 spec/models/section_spec.rb
adminpanel-1.1.0 spec/models/section_spec.rb
adminpanel-1.0.0 spec/models/section_spec.rb