Sha256: c4c938f1b5fa56186e39dc0e485b5cd08bfb1e3385393cb2de664c23749993f3

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'
require 'support/test_database'

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

3 entries across 3 versions & 1 rubygems

Version Path
adminpanel-1.2.12 spec/models/section_spec.rb
adminpanel-1.2.11 spec/models/section_spec.rb
adminpanel-1.2.10 spec/models/section_spec.rb