From 1c1e69b636f82a8f1e8d6a10d67c264fc86825de Mon Sep 17 00:00:00 2001 From: Ion Biziiac Date: Thu, 31 Jul 2014 15:57:34 +0300 Subject: [PATCH] Add specs for Fix forum topics are not copied on project copy --- spec/models/project/copy_spec.rb | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/spec/models/project/copy_spec.rb b/spec/models/project/copy_spec.rb index a05db67ee1..501d866153 100644 --- a/spec/models/project/copy_spec.rb +++ b/spec/models/project/copy_spec.rb @@ -338,16 +338,33 @@ describe Project::Copy do end describe :copy_boards do - before do - FactoryGirl.create(:board, project: project) + let(:board) { FactoryGirl.create(:board, project: project) } - copy.send(:copy_boards, project) - copy.save + context "boards are copied" do + before do + copy.send(:copy_boards, project) + copy.save + end + + subject { copy.boards.count } + + it { should == project.boards.count } end - subject { copy.boards.count } + context "board topics are copied" do + before do + topic = FactoryGirl.create(:message, board: board) + message = FactoryGirl.create(:message, board: board, parent_id: topic.id) + + copy.send(:copy_boards, project) + copy.save + end - it { should == project.boards.count } + it "should copy topics without replies" do + expect(copy.boards.first.topics.count).to eq(project.boards.first.topics.count) + expect(copy.boards.first.messages.count).to_not eq(project.boards.first.messages.count) + end + end end describe :copy_versions do