First fix in the model specs, more to be done, mostly event mocking it seems
This commit is contained in:
@@ -9,6 +9,7 @@ describe Order do
|
|||||||
let(:list) { create :list, supplier: supplier, table: table, user_ids: [user.id] }
|
let(:list) { create :list, supplier: supplier, table: table, user_ids: [user.id] }
|
||||||
let(:order_options) { {supplier: supplier, list: list, state: 'placed'} }
|
let(:order_options) { {supplier: supplier, list: list, state: 'placed'} }
|
||||||
let(:order) { create :order, order_options }
|
let(:order) { create :order, order_options }
|
||||||
|
|
||||||
subject { order }
|
subject { order }
|
||||||
|
|
||||||
its(:placed?) { should be true }
|
its(:placed?) { should be true }
|
||||||
@@ -16,12 +17,15 @@ describe Order do
|
|||||||
|
|
||||||
describe 'count_active_for_supplier_and_list' do
|
describe 'count_active_for_supplier_and_list' do
|
||||||
before { order }
|
before { order }
|
||||||
|
|
||||||
it 'counts active orders for a list with objects' do
|
it 'counts active orders for a list with objects' do
|
||||||
Order.count_active_for_supplier_and_list(supplier, list).should == 1
|
Order.count_active_for_supplier_and_list(supplier, list).should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'counts active orders for a list with ids' do
|
it 'counts active orders for a list with ids' do
|
||||||
Order.count_active_for_supplier_and_list(supplier.id, list.id).should == 1
|
Order.count_active_for_supplier_and_list(supplier.id, list.id).should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not count inactive orders' do
|
it 'does not count inactive orders' do
|
||||||
order.close!
|
order.close!
|
||||||
Order.count_active_for_supplier_and_list(supplier, list).should == 0
|
Order.count_active_for_supplier_and_list(supplier, list).should == 0
|
||||||
@@ -31,6 +35,7 @@ describe Order do
|
|||||||
|
|
||||||
describe '.for_supplier' do
|
describe '.for_supplier' do
|
||||||
before { order }
|
before { order }
|
||||||
|
|
||||||
it 'works' do
|
it 'works' do
|
||||||
Order.for_supplier(supplier).should == [order]
|
Order.for_supplier(supplier).should == [order]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe :section do
|
describe :section do
|
||||||
|
let(:supplier) { create :supplier }
|
||||||
before :each do
|
before :each do
|
||||||
@section = build :section, path: [[10, 30], [20,30], [20,40], [10, 40]]
|
@section = build :section, supplier: supplier, path: [[10, 30], [20,30], [20,40], [10, 40]]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates without problem" do
|
it "creates without problem" do
|
||||||
@@ -23,6 +24,7 @@ describe :section do
|
|||||||
it "should persist width property through database" do
|
it "should persist width property through database" do
|
||||||
@section.width = 3.2
|
@section.width = 3.2
|
||||||
@section.save
|
@section.save
|
||||||
|
|
||||||
@reloaded_section = Section.find(@section.id)
|
@reloaded_section = Section.find(@section.id)
|
||||||
@reloaded_section.width.should == 3.2
|
@reloaded_section.width.should == 3.2
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user