Permalink
Browse files

Merge now also handles comments

  • Loading branch information...
1 parent ad8f828 commit f549c9bce4fdb761c080f2e8acd7618c36a9626d @ndbroadbent ndbroadbent committed Oct 29, 2010
@@ -34,7 +34,7 @@ else # <----------------------------------------- Show [Edit Account] or [Merge
# Only call this method if we are calling a default edit, not a merge.
if edit_action == "edit"
- page[:account_first_name].focus
+ page[:account_name].focus
end
end
@@ -38,6 +38,8 @@ Feature: Merge Accounts
And I should see "Test Opportunity Two"
And I should see "Test Email One"
And I should see "Test Email Two"
+ And I should see "Test Comment One"
+ And I should see "Test Comment Two"
And I should see "Test Contact One"
And I should see "Test Contact Two"
@@ -38,6 +38,8 @@ Feature: Merge Contacts
And I should see "Test Opportunity Two"
And I should see "Test Email One"
And I should see "Test Email Two"
+ And I should see "Test Comment One"
+ And I should see "Test Comment Two"
Scenario: User should be able to reverse the master and duplicate contacts
Given a logged in user
@@ -11,6 +11,8 @@
@emails = %w(One Two).map {|n| Factory(:email, :mediator => @dup_account,
:subject => "Test Email #{n}")}
+ @comments = %w(One Two).map {|n| Factory(:comment, :commentable => @dup_account,
+ :comment => "Test Comment #{n}")}
@opportunities = %w(One Two).map {|n| Factory(:account_opportunity,
:account => @dup_account,
@@ -12,6 +12,8 @@
@emails = %w(One Two).map {|n| Factory(:email, :mediator => @dup_contact,
:subject => "Test Email #{n}")}
+ @comments = %w(One Two).map {|n| Factory(:comment, :commentable => @dup_contact,
+ :comment => "Test Comment #{n}")}
@opportunities = %w(One Two).map {|n| Factory(:contact_opportunity,
:contact => @dup_contact,
View
@@ -1,10 +1,8 @@
-require 'merge/contacts'
-require 'merge/accounts'
-require 'merge/merge_view_hooks'
+# Require all files in lib/crm_* plugin directory
+Dir.glob(File.join(File.dirname(__FILE__), "crm_*", "*.rb")).each {|f| require f }
# Require *.rb from app_extensions
require 'find'
Find.find(File.join(File.dirname(__FILE__), '..', 'app_extensions')) do |file|
require file if file.end_with?(".rb")
end
-
@@ -31,6 +31,9 @@ def merge_with(master_account, ignored_attr = [])
self.emails.each do |e|
e.mediator = master_account; e.save!
end
+ self.comments.each do |c|
+ c.commentable = master_account; c.save!
+ end
self.opportunities.each do |o|
o.account = master_account; o.save!
@@ -28,6 +28,9 @@ def merge_with(master_contact, ignored_attr = [])
self.emails.each do |e|
e.mediator = master_contact; e.save!
end
+ self.comments.each do |c|
+ c.commentable = master_contact; c.save!
+ end
# Find all ContactOpportunity records with the duplicate contact,
# and only add the master contact if it is not already added to the opportunity.
ContactOpportunity.find_all_by_contact_id(self.id).each do |co|
File renamed without changes.
@@ -13,16 +13,19 @@
4.times do
Factory(:email, :mediator => @account)
Factory(:email, :mediator => @dup_account)
+ Factory(:comment, :commentable => @account)
+ Factory(:comment, :commentable => @dup_account)
end
end
it "should be able to merge itself into another account" do
# Store the attributes we want to match
dup_account_attr = @dup_account.merge_attributes
- dup_has_many_hash = {:emails => @dup_account.emails,
- :contacts => @dup_account.contacts,
- :opportunities => @dup_account.opportunities,
- :tasks => @dup_account.tasks}
+ dup_has_many_hash = {:emails => @dup_account.emails.dup,
+ :comments => @dup_account.comments.dup,
+ :contacts => @dup_account.contacts.dup,
+ :opportunities => @dup_account.opportunities.dup,
+ :tasks => @dup_account.tasks.dup}
@dup_account.merge_with(@account)
@@ -13,15 +13,18 @@
4.times do
Factory(:email, :mediator => @contact)
Factory(:email, :mediator => @dup_contact)
+ Factory(:comment, :commentable => @contact)
+ Factory(:comment, :commentable => @dup_contact)
end
end
it "should be able to merge itself into another contact" do
# Store the attributes we want to match
dup_contact_attr = @dup_contact.merge_attributes
- dup_has_many_hash = {:emails => @dup_contact.emails,
- :opportunities => @dup_contact.opportunities,
- :tasks => @dup_contact.tasks}
+ dup_has_many_hash = {:emails => @dup_contact.emails.dup,
+ :comments => @dup_contact.comments.dup,
+ :opportunities => @dup_contact.opportunities.dup,
+ :tasks => @dup_contact.tasks.dup}
@dup_contact.merge_with(@contact)

0 comments on commit f549c9b

Please sign in to comment.