Make section table view work request and event based

This commit is contained in:
2013-03-10 12:48:03 +01:00
parent cc13797f5a
commit 5eac918255
11 changed files with 164 additions and 38 deletions
+26 -1
View File
@@ -3,8 +3,8 @@
require 'spec_helper'
describe Table do
let(:supplier){ create(:supplier) }
describe 'for_supplier' do
let(:supplier){ create(:supplier) }
let(:options){ Hash.new }
subject{ Table.for_supplier(supplier, options) }
it "should return an empty array by default" do
@@ -46,4 +46,29 @@ describe Table do
end
end
describe 'enrich_active_list_id' do
before do
@table1 = create :table, supplier: supplier, number: 2
@list = create :list, supplier: supplier, table: @table1, state: 'active'
end
# False passes can be possible when list is not valid
it 'has created a list' do
@list.id.should be_present
end
it 'enriches active_list_id using a single object' do
Table.enrich_active_list_id(@table1).active_list_id.should == @list.id
end
it 'enriches active_list_id using an array' do
Table.enrich_active_list_id([@table1]).first.active_list_id.should == @list.id
end
it "does not enrich non active lists" do
@list.update_attributes(state: 'closed')
Table.enrich_active_list_id([@table1]).first.active_list_id.should be_nil
end
end
end