Files
mozo-backend/spec/models/section_spec.rb
T

64 lines
1.7 KiB
Ruby

require 'spec_helper'
describe :section do
before :each do
@section = build :section, path: [[10, 30], [20,30], [20,40], [10, 40]]
end
it "creates without problem" do
expect{ @section.save }.not_to raise_error
end
describe :path do
describe :width do
it "should have 20 width when initialized" do
Section.new.width.should == 20
end
it "should have new width when it is defined using a setter" do
@section.width = 3.2
@section.width.should == 3.2
end
it "should persist width property through database" do
@section.width = 3.2
@section.save
@reloaded_section = Section.find(@section.id)
@reloaded_section.width.should == 3.2
end
end
describe :height do
it "should have 30 height when initialized" do
Section.new.height.should == 30
end
it "should have new height when it is defined using a setter" do
@section.height = 3.2
@section.height.should == 3.2
end
it "should persist height property through database" do
@section.height = 3.2
@section.save
@reloaded_section = Section.find(@section.id)
@reloaded_section.height.should == 3.2
end
end
end
describe '#tables_with_active_list_id' do
it 'caches the result for tables call' do
section = create :section
table = create :table, section: section
section = Section.find section.id # ensure a totally clean object
section.tables_with_active_list_id
Table.database.stub(:view).and_raise 'No view should be called here'
expect{ section.tables }.not_to raise_error
end
end
end