@item = FactoryGirl.create :sheet_install_a_with_sheet_panels, author: @author_yas
end
- it 'ã\83\96ã\83¼ã\82¹ã\83\88ã\83¡ã\83\83ã\82»ã\83¼ã\82¸ã\82\92ã\83ªã\83¼ã\83\95ã\81«ä¼\9dæ\90¬ã\81\99る' do
+ it 'ã\82³ã\83\94ã\83¼ã\81\97ã\81¦ã\81»ã\81\97ã\81\8fã\81ªã\81\84ã\82«ã\83©ã\83 ã\82\92å\8f\96ã\82\8aé\99¤ã\81\84ã\81¦ã\81\84る' do
end
end
end
end
-#
-describe ScrollPanel do
- include LeafMacros
+# I/O処理については、マニフェストで動作が変わることがないのでコマでのみテストしておく
+describe Panel do
+ include RootMacros
before do
@admin =FactoryGirl.create :admin
@user_yas = FactoryGirl.create :user_yas_with_owner
@user_rom = FactoryGirl.create :user_rom
@author_yas = @user_yas.author
- @model = ScrollPanel
+ @model = Panel
end
- describe 'new_tに於いて' do
+ describe 'エレメント取得parts_elementに於いて' do
before do
- @scroll = FactoryGirl.create :scroll_hello, author: @author_yas
+ @item = FactoryGirl.create :sheet_install_a_with_sheet_panels, author: @author_yas
end
- context 'オーソドックスなデータのとき' do
- it 'cut' do
- expect(@model.new_t(@scroll.id)).to eq 0
- end
-
+ it '順番にかかわらずぶら下がるエレメントすべてをリストで取得してくる' do
+ end
+ end
+
+ describe '重ね合わせ順のエレメント取得zorderd_elementsに於いて' do
+ before do
+ @item = FactoryGirl.create :sheet_install_a_with_sheet_panels, author: @author_yas
end
- context 'オーソドックスなデータのとき' do
- it 'cut' do
- @item = FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
- expect(@model.new_t(@scroll.id)).to eq 1
- end
-
- it 'cut' do
- @item = FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
- @item = FactoryGirl.create :scroll_panel_plain, z: 2, t: 1, scroll: @scroll, panel: @panel
- @item = FactoryGirl.create :scroll_panel_plain, z: 3, t: 2, scroll: @scroll, panel: @panel
- expect(@model.new_t(@scroll.id)).to eq 3
- end
-
+ it 'エレメントをすべてリストで取得してくる' do
+ end
+ end
+
+ describe '重ね合わせ順のエレメント取得scenario_elementsに於いて' do
+ before do
+ @item = FactoryGirl.create :sheet_install_a_with_sheet_panels, author: @author_yas
end
+ it 'エレメントをすべてリストで取得してくる' do
+ end
end
- describe 'collect_tに於いて' do
+ describe 'new_tに於いて' do
before do
- @dummy = FactoryGirl.create :scroll_great_with_scroll_panels, author: @author_yas
@scroll = FactoryGirl.create :scroll_hello, author: @author_yas
end
- context 'オーソドックスなデータのとき' do
- it 'cut' do
- expect(@model.collect_t(@scroll.id)).to be_empty
- end
-
+ it 'オフセットはゼロなのでエレメントの総数と一致する' do
+ expect(@model.new_t(@scroll.id)).to eq 0
end
- context 'オーソドックスなデータのとき' do
- it 'cut' do
- @item = FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
- expect(@model.collect_t(@scroll.id)).to eq [0]
- end
-
- it 'cut' do
- @item = FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
- @item = FactoryGirl.create :scroll_panel_plain, z: 2, t: 1, scroll: @scroll, panel: @panel
- @item = FactoryGirl.create :scroll_panel_plain, z: 3, t: 2, scroll: @scroll, panel: @panel
- expect(@model.collect_t(@scroll.id)).to eq [0, 1, 2]
- end
-
+ end
+
+ describe 'collect_tに於いて' do
+ before do
+ @dummy = FactoryGirl.create :scroll_great_with_scroll_panels, author: @author_yas
+ @scroll = FactoryGirl.create :scroll_hello, author: @author_yas
end
+ it 'オフセットは1なのでエレメントの総数+1と一致する' do
+ expect(@model.collect_t(@scroll.id)).to be_empty
+ end
end
- describe 'tチェックに於いて' do
+ describe 'validate_childに於いて' do
before do
@sheet = FactoryGirl.create :sheet, :author_id => @author.id
@panel = FactoryGirl.create :panel, :author_id => @author.id
@item = FactoryGirl.build :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
end
- context 'つつがなく終わるとき' do
- it 't収集を依頼している' do
- SheetPanel.should_receive(:collect_t).with(any_args).exactly(1)
- SheetPanel.stub(:collect_t).with(any_args).and_return([])
- SheetPanel.stub(:serial?).with(any_args).and_return(true)
- r = SheetPanel.validate_t @item
- end
- it '収集したtをシリアライズチェック依頼している' do
- SheetPanel.stub(:collect_t).with(any_args).and_return([])
- SheetPanel.should_receive(:serial?).with(any_args).exactly(1)
- SheetPanel.stub(:serial?).with(any_args).and_return(true)
+ #実データで最低限のチェックを
+ context '正常のとき' do
+ it '真を返している' do
+ @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
r = SheetPanel.validate_t @item
+ r.should be_true
end
end
- #実データでチェック
- #依頼チェックだけでは不安なので最低限のチェックを
- context '新規のとき' do
- it '一件だけで正常通過している' do
- @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
- r = SheetPanel.validate_t @item
+ context '重ね合わせ順が壊れているとき' do
+ it '偽を返している' do
+ r = SheetPanel.validate_t @item2
r.should be_true
end
end
- context '既存のとき' do
- it '2件目を作っても正常通過している' do
- @item = FactoryGirl.create :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
- @item2 = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 1
+ context 'シナリオ順が壊れているとき' do
+ it '偽を返している' do
r = SheetPanel.validate_t @item2
r.should be_true
end
end
end
+
describe '保存に於いて' do
before do
@sheet = FactoryGirl.create :sheet, :author_id => @author.id
@panel = FactoryGirl.create :panel, :author_id => @author.id
@item = FactoryGirl.build :sheet_panel, :t => nil, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
end
- context 'つつがなく終わるとき' do
- it '編集許可チェックを依頼している' do
- SheetPanel.any_instance.stub(:allow?).with(any_args).and_return(true)
- SheetPanel.any_instance.should_receive(:allow?).with(any_args).exactly(1)
- r = @item.store
- end
- it '順序入れ替えを依頼している' do
- SheetPanel.any_instance.stub(:rotate).with(any_args).and_return(0)
- SheetPanel.any_instance.should_receive(:rotate).with(any_args).exactly(1)
- SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
- SheetPanel.stub(:validate_t).with(any_args).and_return(true)
- r = @item.store
- end
- it '保存を依頼している' do
- SheetPanel.stub(:new_t).with(any_args).and_return(0)
- SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
- SheetPanel.any_instance.should_receive(:save).with(any_args).exactly(1)
- SheetPanel.stub(:validate_t).with(any_args).and_return(true)
- r = @item.store
- end
- it 'tのシリアライズチェックを依頼している' do
- SheetPanel.stub(:new_t).with(any_args).and_return(0)
- SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
- SheetPanel.stub(:validate_t).with(any_args).and_return(true)
- SheetPanel.should_receive(:validate_t).with(any_args).exactly(1)
- r = @item.store
- end
- end
#入れ替えテストと同じテストを実施。こちらはシフトだけでなく本尊も更新されている
context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で2に挿入したとき' do
before do
end
describe '切り詰め処理つき削除に於いて' do
before do
- @sheet = FactoryGirl.create :sheet, :author_id => @author.id
- @panel = FactoryGirl.create :panel, :author_id => @author.id
- @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+ @dummy = FactoryGirl.create :scroll_great_with_scroll_panels, author: @author_yas
+ @scroll = FactoryGirl.create :scroll_hello, author: @author_yas
+ @panel = FactoryGirl.create :panel_hello, author: @author_yas
+ @item = FactoryGirl.create :scroll_panel_plain, t: 0, scroll: @scroll, panel: @panel
end
context 'つつがなく終わるとき' do
it '削除される' do
- lambda{
+ expect {
@item.destroy_and_shorten
- }.should change(SheetPanel, :count ).by(-1)
+ }.to change(ScrollPanel, :count ).by(-1)
end
it 'Trueを返す' do
r = @item.destroy_and_shorten
- r.should be_true
+ expect(r).to be_true
end
end
context '削除に失敗したとき' do
before do
- SheetPanel.any_instance.stub(:destroy).and_return(false)
+ ScrollPanel.any_instance.stub(:destroy).and_return(false)
end
it 'ロールバックされる' do
- lambda{
+ expect {
@item.destroy_and_shorten
- }.should_not change(SheetPanel, :count )
+ }.to change(ScrollPanel, :count )
end
it 'Falseを返す' do
r = @item.destroy_and_shorten
- r.should be_false
+ expect(r).to be_false
end
end
#連携テスト。切り詰めが直接DBをいじる
context '2件で先頭を削除したとき' do
before do
- @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+ @item2 = FactoryGirl.create :scroll_panel_plain, t: 1, scroll: @scroll, panel: @panel
end
it '行が削除される' do
- lambda{
+ expect {
@item.destroy_and_shorten
- }.should change(SheetPanel, :count ).by(-1)
+ }.to change(ScrollPanel, :count ).by(-1)
end
it '先頭は削除される' do
@item.destroy_and_shorten
- lambda{
- SheetPanel.find @item.id
- }.should raise_error(ActiveRecord::RecordNotFound)
+ expect {
+ ScrollPanel.find @item.id
+ }.to raise_error(ActiveRecord::RecordNotFound)
end
it '2件目は前に詰められる' do
@item.destroy_and_shorten
@item2.reload
- @item2.t.should eq 0
+ expect(@item2.t).to eq 0
end
end
context '3件で先頭を削除したとき' do
before do
- @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
- @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+ @item2 = FactoryGirl.create :scroll_panel_plain, t: 1, scroll: @scroll, panel: @panel
+ @item3 = FactoryGirl.create :scroll_panel_plain, t: 2, scroll: @scroll, panel: @panel
end
it '行が削除される' do
- lambda{
+ expect {
@item.destroy_and_shorten
- }.should change(SheetPanel, :count ).by(-1)
+ }.to change(ScrollPanel, :count ).by(-1)
end
it '先頭は削除される' do
@item.destroy_and_shorten
- lambda{
- SheetPanel.find @item.id
- }.should raise_error(ActiveRecord::RecordNotFound)
+ expect {
+ ScrollPanel.find @item.id
+ }.to raise_error(ActiveRecord::RecordNotFound)
end
it '2件目は前に詰められる' do
@item.destroy_and_shorten
@item2.reload
- @item2.t.should eq 0
+ expect(@item2.t).to eq 0
end
it '3件目は前に詰められる' do
@item.destroy_and_shorten
@item3.reload
- @item3.t.should eq 1
+ expect(@item3.t).to eq 1
end
end
context '5件で3件目を削除したとき' do
before do
- @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
- @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
- @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
- @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+ @item2 = FactoryGirl.create :scroll_panel_plain, t: 1, scroll: @scroll, panel: @panel
+ @item3 = FactoryGirl.create :scroll_panel_plain, t: 2, scroll: @scroll, panel: @panel
+ @item4 = FactoryGirl.create :scroll_panel_plain, t: 3, scroll: @scroll, panel: @panel
+ @item5 = FactoryGirl.create :scroll_panel_plain, t: 4, scroll: @scroll, panel: @panel
end
it '行が削除される' do
- lambda{
+ expect {
@item3.destroy_and_shorten
- }.should change(SheetPanel, :count ).by(-1)
+ }.to change(ScrollPanel, :count ).by(-1)
end
it '1件目は変化がない' do
@item3.destroy_and_shorten
@item.reload
- @item.t.should eq 0
+ expect(@item.t).to eq 0
end
it '2件目は変化がない' do
@item3.destroy_and_shorten
@item2.reload
- @item2.t.should eq 1
+ expect(@item2.t).to eq 1
end
it '3件目は削除される' do
@item3.destroy_and_shorten
- lambda{
- SheetPanel.find @item3.id
- }.should raise_error(ActiveRecord::RecordNotFound)
+ expect {
+ ScrollPanel.find @item3.id
+ }.to raise_error(ActiveRecord::RecordNotFound)
end
it '4件目は前に詰められる' do
@item3.destroy_and_shorten
@item4.reload
- @item4.t.should eq 2
+ expect(@item4.t).to eq 2
end
it '5件目は前に詰められる' do
@item3.destroy_and_shorten
@item5.reload
- @item5.t.should eq 3
+ expect(@item5.t).to eq 3
end
end
#ロールバックテスト。切り詰めが直接DBをいじるので、すべてのケースで確実にロールバックを確認する