Skip to content

Commit

Permalink
Merge comment with problem during the merge of some problem
Browse files Browse the repository at this point in the history
see #477
  • Loading branch information
shingara committed Jun 18, 2013
1 parent 34b283a commit ee84980
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/interactors/problem_merge.rb
Expand Up @@ -11,7 +11,9 @@ def initialize(*problems)

def merge
child_problems.each do |problem|
merged_problem.errs.concat Err.where(:problem_id => problem.id)
merged_problem.errs.concat problem.errs
merged_problem.comments.concat problem.comments
problem.reload # deference all associate objet to avoid delete him after
ProblemDestroy.execute(problem)
end
reset_cached_attributes
Expand Down
14 changes: 14 additions & 0 deletions spec/interactors/problem_merge_spec.rb
Expand Up @@ -29,6 +29,7 @@
let(:merged_errs) { problem_1.errs }
let!(:notice) { Fabricate(:notice, :err => first_errs.first) }
let!(:notice_1) { Fabricate(:notice, :err => merged_errs.first) }

it 'delete one of problem' do
expect {
problem_merge.merge
Expand All @@ -44,5 +45,18 @@
ProblemUpdaterCache.should_receive(:new).with(problem).and_return(mock(:update => true))
problem_merge.merge
end

context "with problem with comment" do
let!(:comment) { Fabricate(:comment, :err => problem ) }
let!(:comment_2) { Fabricate(:comment, :err => problem_1, :user => comment.user ) }
it 'merge comment' do
expect {
problem_merge.merge
}.to change{
problem.comments.size
}.from(1).to(2)
expect(comment_2.reload.err).to eq problem
end
end
end
end

0 comments on commit ee84980

Please sign in to comment.