Sha256: 52d657b88833327b5b6ea83a6ca531bfc941fbb4d6c501437ea8b48b19c742ea

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 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 }

	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.all.to_sql).to eq Adminpanel::Section.reorder('').order('page ASC').to_sql}
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adminpanel-2.1.0 spec/models/section_spec.rb
adminpanel-2.0.1 spec/models/section_spec.rb
adminpanel-2.0.0 spec/models/section_spec.rb