alchemy_crm 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/Gemfile +10 -11
  2. data/alchemy_crm.gemspec +21 -21
  3. data/app/assets/javascripts/alchemy_crm/alchemy_crm.base.js +54 -54
  4. data/app/assets/stylesheets/alchemy_crm/base.css.scss +199 -199
  5. data/app/controllers/alchemy_crm/admin/base_controller.rb +5 -5
  6. data/app/controllers/alchemy_crm/admin/contact_groups_controller.rb +15 -15
  7. data/app/controllers/alchemy_crm/admin/contacts_controller.rb +95 -95
  8. data/app/controllers/alchemy_crm/admin/deliveries_controller.rb +66 -66
  9. data/app/controllers/alchemy_crm/admin/elements_controller_extension.rb +23 -23
  10. data/app/controllers/alchemy_crm/admin/mailings_controller.rb +44 -44
  11. data/app/controllers/alchemy_crm/admin/newsletters_controller.rb +16 -16
  12. data/app/controllers/alchemy_crm/admin/tags_controller.rb +60 -59
  13. data/app/controllers/alchemy_crm/base_controller.rb +3 -3
  14. data/app/controllers/alchemy_crm/contacts_controller.rb +88 -88
  15. data/app/controllers/alchemy_crm/mailings_controller.rb +16 -16
  16. data/app/controllers/alchemy_crm/recipients_controller.rb +30 -30
  17. data/app/controllers/alchemy_crm/subscriptions_controller.rb +54 -54
  18. data/app/helpers/alchemy/pages_helper_extension.rb +14 -14
  19. data/app/helpers/alchemy_crm/admin/base_helper.rb +8 -8
  20. data/app/helpers/alchemy_crm/mailings_helper.rb +175 -175
  21. data/app/mailers/alchemy_crm/bounce_receiver.rb +9 -9
  22. data/app/mailers/alchemy_crm/contacts_mailer.rb +21 -21
  23. data/app/mailers/alchemy_crm/mailings_mailer.rb +46 -46
  24. data/app/mailers/alchemy_crm/subscriptions_mailer.rb +12 -12
  25. data/app/models/alchemy/essence_element_teaser.rb +14 -14
  26. data/app/models/alchemy_crm/contact.rb +260 -260
  27. data/app/models/alchemy_crm/contact_group.rb +15 -15
  28. data/app/models/alchemy_crm/contact_group_filter.rb +17 -17
  29. data/app/models/alchemy_crm/delivery.rb +54 -54
  30. data/app/models/alchemy_crm/element_extension.rb +23 -23
  31. data/app/models/alchemy_crm/mailing.rb +90 -90
  32. data/app/models/alchemy_crm/newsletter.rb +33 -33
  33. data/app/models/alchemy_crm/reaction.rb +5 -5
  34. data/app/models/alchemy_crm/recipient.rb +46 -46
  35. data/app/models/alchemy_crm/subscription.rb +4 -4
  36. data/app/views/alchemy/admin/elements/fill.js.erb +11 -11
  37. data/app/views/alchemy/elements/_newsletter_article_view.html.erb +14 -14
  38. data/app/views/alchemy/elements/_newsletter_greeting_view.html.erb +9 -9
  39. data/app/views/alchemy/elements/_newsletter_signout_form_view.html.erb +18 -18
  40. data/app/views/alchemy/elements/_newsletter_signup_form_view.html.erb +62 -62
  41. data/app/views/alchemy/essences/_essence_element_teaser_editor.html.erb +29 -29
  42. data/app/views/alchemy/newsletter_layouts/_standard.html.erb +37 -37
  43. data/app/views/alchemy_crm/admin/contact_groups/_contact_group.html.erb +30 -30
  44. data/app/views/alchemy_crm/admin/contact_groups/_filter.html.erb +28 -28
  45. data/app/views/alchemy_crm/admin/contact_groups/_form.html.erb +45 -45
  46. data/app/views/alchemy_crm/admin/contact_groups/_tag.html.erb +4 -4
  47. data/app/views/alchemy_crm/admin/contact_groups/add_filter.js.erb +7 -7
  48. data/app/views/alchemy_crm/admin/contact_groups/index.html.erb +28 -28
  49. data/app/views/alchemy_crm/admin/contacts/_contact.html.erb +42 -42
  50. data/app/views/alchemy_crm/admin/contacts/_form.html.erb +76 -76
  51. data/app/views/alchemy_crm/admin/contacts/import.html.erb +27 -27
  52. data/app/views/alchemy_crm/admin/contacts/index.html.erb +39 -39
  53. data/app/views/alchemy_crm/admin/contacts/vcf_import_result.html.erb +24 -24
  54. data/app/views/alchemy_crm/admin/deliveries/_delivery.html.erb +30 -30
  55. data/app/views/alchemy_crm/admin/deliveries/_form.html.erb +61 -61
  56. data/app/views/alchemy_crm/admin/deliveries/_recipient.html.erb +36 -36
  57. data/app/views/alchemy_crm/admin/deliveries/index.html.erb +21 -21
  58. data/app/views/alchemy_crm/admin/deliveries/show.html.erb +61 -61
  59. data/app/views/alchemy_crm/admin/elements/teasables.html.erb +53 -53
  60. data/app/views/alchemy_crm/admin/mailings/_form.html.erb +41 -41
  61. data/app/views/alchemy_crm/admin/mailings/_mailing.html.erb +73 -73
  62. data/app/views/alchemy_crm/admin/mailings/edit_content.html.erb +170 -170
  63. data/app/views/alchemy_crm/admin/mailings/import_result.html.erb +18 -18
  64. data/app/views/alchemy_crm/admin/mailings/index.html.erb +25 -25
  65. data/app/views/alchemy_crm/admin/newsletters/_form.html.erb +52 -52
  66. data/app/views/alchemy_crm/admin/newsletters/_tag_with_radiobutton.html.erb +5 -5
  67. data/app/views/alchemy_crm/admin/newsletters/index.html.erb +29 -29
  68. data/app/views/alchemy_crm/admin/newsletters/new.html.erb +4 -4
  69. data/app/views/alchemy_crm/admin/tags/_radio_tag.html.erb +4 -4
  70. data/app/views/alchemy_crm/admin/tags/_tag.html.erb +30 -30
  71. data/app/views/alchemy_crm/admin/tags/edit.html.erb +32 -32
  72. data/app/views/alchemy_crm/admin/tags/index.html.erb +23 -23
  73. data/app/views/alchemy_crm/admin/tags/new.html.erb +14 -14
  74. data/app/views/alchemy_crm/contacts_mailer/signout_mail.html.erb +6 -6
  75. data/app/views/alchemy_crm/contacts_mailer/signout_mail.text.erb +2 -2
  76. data/app/views/alchemy_crm/contacts_mailer/signup_mail.html.erb +9 -9
  77. data/app/views/alchemy_crm/contacts_mailer/signup_mail.text.erb +2 -2
  78. data/app/views/alchemy_crm/mailings_mailer/verification_mail.html.erb +9 -9
  79. data/app/views/alchemy_crm/subscriptions/index.html.erb +4 -4
  80. data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.html.erb +25 -25
  81. data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.text.erb +2 -2
  82. data/app/views/csv_magic/import_errors.html.erb +23 -23
  83. data/app/views/csv_magic/mapper.html.erb +46 -46
  84. data/app/views/layouts/alchemy_crm/mailings.html.erb +177 -177
  85. data/config/initializers/assets.rb +2 -2
  86. data/config/locales/alchemy_crm.de.yml +1 -1
  87. data/config/locales/alchemy_crm.en.yml +1 -0
  88. data/config/locales/localized_country_select.de.rb +260 -260
  89. data/config/locales/localized_country_select.en.rb +274 -274
  90. data/config/routes.rb +67 -67
  91. data/db/migrate/20111104125306_remove_sent_mailing_pdf_id_from_sent_mailings.rb +1 -1
  92. data/db/migrate/20111124145923_namespace_alchemy_crm_models.rb +13 -13
  93. data/db/migrate/20120307160721_rename_alchemy_crm_recipients_sent_mailing_id.rb +3 -3
  94. data/db/migrate/20120320103412_add_indexes_to_alchemy_crm_sha1_columns.rb +3 -3
  95. data/db/migrate/20120327174301_add_more_indexes_to_alchemy_crm_tables.rb +10 -10
  96. data/lib/alchemy_crm.rb +15 -15
  97. data/lib/alchemy_crm/bounced_delivery.rb +38 -38
  98. data/lib/alchemy_crm/config.rb +25 -25
  99. data/lib/alchemy_crm/engine.rb +31 -31
  100. data/lib/alchemy_crm/i18n_helpers.rb +28 -28
  101. data/lib/alchemy_crm/newsletter_layout.rb +28 -28
  102. data/lib/alchemy_crm/seeder.rb +26 -26
  103. data/lib/alchemy_crm/version.rb +1 -1
  104. data/lib/generators/alchemy_crm/scaffold/files/newsletters.html.erb +19 -19
  105. data/lib/generators/alchemy_crm/scaffold/scaffold_generator.rb +2 -2
  106. data/lib/tasks/alchemy_crm.rake +22 -22
  107. data/lib/tasks/routes.rake +25 -25
  108. data/spec/config_spec.rb +24 -24
  109. data/spec/controllers/alchemy_crm/contacts_controller_spec.rb +147 -147
  110. data/spec/controllers/alchemy_crm/mailings_controller_spec.rb +62 -62
  111. data/spec/controllers/alchemy_crm/recipients_controller_spec.rb +109 -109
  112. data/spec/helpers/alchemy_crm/mailings_helper_spec.rb +165 -165
  113. data/spec/mailers/alchemy_crm/contacts_mailer_spec.rb +84 -84
  114. data/spec/mailers/alchemy_crm/mailings_mailer_spec.rb +29 -29
  115. data/spec/models/alchemy_crm/contact_group_spec.rb +25 -25
  116. data/spec/models/alchemy_crm/contact_spec.rb +71 -71
  117. data/spec/models/alchemy_crm/delivery_spec.rb +43 -39
  118. data/spec/models/alchemy_crm/mailing_spec.rb +46 -42
  119. data/spec/models/alchemy_crm/newsletter_spec.rb +29 -29
  120. data/spec/spec_helper.rb +36 -36
  121. metadata +6 -8
  122. data/rails/init.rb +0 -1
  123. data/recipes/alchemy-mailings-capistrano-tasks.rb +0 -12
@@ -1,88 +1,88 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module AlchemyCrm
4
- describe ContactsMailer do
5
-
6
- include AlchemyCrm::Engine.routes.url_helpers
7
-
8
- before(:all) do
9
- Alchemy::PageLayout.add({"name" => 'newsletter_mails', "elements" => ['newsletter_signup_mail'], "autogenerate" => ["newsletter_signup_mail"]})
10
- @language_root = Alchemy::Page.create!(:name => 'Language Root', :page_layout => 'standard', :parent_id => Alchemy::Page.root.id, :language => Alchemy::Language.get_default)
11
- @page = Alchemy::Page.create!(:name => 'Newsletter Mails', :page_layout => 'newsletter_mails', :parent_id => @language_root.id, :language => @language_root.language)
12
- @contact = Contact.create!(:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr')
13
- @newsletter = Newsletter.create!(:name => 'Newsletter', :layout => 'standard')
14
- @subscription = Subscription.create!(:contact => @contact, :newsletter => @newsletter, :verified => true, :wants => true)
15
- end
16
-
17
- describe '#signup_mail' do
18
-
19
- before(:all) do
20
- @element = @page.elements.find_by_name(:newsletter_signup_mail)
21
- @element.content_by_name('mail_from').essence.update_attribute(:body, 'frank@dank.com')
22
- @element.content_by_name('subject').essence.update_attribute(:body, 'Welcome, please confirm')
23
- @element.content_by_name('text').essence.update_attribute(:body, 'Hello %{name}, please click %{link}')
24
- @email = ContactsMailer.signup_mail(@contact, @page).deliver
25
- end
26
-
27
- it "should deliver to the contact's email address" do
28
- @email.should deliver_to(@contact.email)
29
- end
30
-
31
- it "should have correct delivered from" do
32
- @email.should deliver_from(@element.ingredient('mail_from'))
33
- end
34
-
35
- it "should contain a link to the confirmation link" do
36
- url_regexp = Regexp.new(Regexp.escape(verify_contact_url(:token => @contact.email_sha1, :host => ActionMailer::Base.default_url_options[:host], :newsletter_ids => @contact.subscriptions.collect(&:newsletter_id))))
37
- @email.should have_body_text(url_regexp)
38
- end
39
-
40
- it "should contain the correct greeting" do
41
- @email.should have_body_text(/#{@contact.fullname}/)
42
- end
43
-
44
- it "should have the correct subject" do
45
- @email.should have_subject(@element.ingredient('subject'))
46
- end
47
-
48
- end
49
-
50
- describe '#signout_mail' do
51
-
52
- before(:all) do
53
- @element = @page.elements.find_by_name(:newsletter_signout_mail)
54
- @element.content_by_name('mail_from').essence.update_attribute(:body, 'frank@dank.com')
55
- @element.content_by_name('subject').essence.update_attribute(:body, 'Byebye, please confirm')
56
- @element.content_by_name('text').essence.update_attribute(:body, 'Hello %{name}, please click %{link}')
57
- @email = ContactsMailer.signout_mail(@contact, @page).deliver
58
- end
59
-
60
- it "should deliver to the contact's email address" do
61
- @email.should deliver_to(@contact.email)
62
- end
63
-
64
- it "should have correct delivered from" do
65
- @email.should deliver_from(@element.ingredient('mail_from'))
66
- end
67
-
68
- it "should contain a link to the confirmation link" do
69
- @email.should have_body_text(/#{disable_contact_url(:token => @contact.email_sha1, :host => ActionMailer::Base.default_url_options[:host])}/)
70
- end
71
-
72
- it "should contain the correct greeting" do
73
- @email.should have_body_text(/#{@contact.fullname}/)
74
- end
75
-
76
- it "should have the correct subject" do
77
- @email.should have_subject(@element.ingredient('subject'))
78
- end
79
-
80
- end
81
-
82
- after(:all) do
83
- @language_root.destroy
84
- @contact.destroy
85
- end
86
-
87
- end
4
+ describe ContactsMailer do
5
+
6
+ include AlchemyCrm::Engine.routes.url_helpers
7
+
8
+ before(:all) do
9
+ Alchemy::PageLayout.add({"name" => 'newsletter_mails', "elements" => ['newsletter_signup_mail'], "autogenerate" => ["newsletter_signup_mail"]})
10
+ @language_root = Alchemy::Page.create!(:name => 'Language Root', :page_layout => 'standard', :parent_id => Alchemy::Page.root.id, :language => Alchemy::Language.get_default)
11
+ @page = Alchemy::Page.create!(:name => 'Newsletter Mails', :page_layout => 'newsletter_mails', :parent_id => @language_root.id, :language => @language_root.language)
12
+ @contact = Contact.create!(:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr')
13
+ @newsletter = Newsletter.create!(:name => 'Newsletter', :layout => 'standard')
14
+ @subscription = Subscription.create!(:contact => @contact, :newsletter => @newsletter, :verified => true, :wants => true)
15
+ end
16
+
17
+ describe '#signup_mail' do
18
+
19
+ before(:all) do
20
+ @element = @page.elements.find_by_name(:newsletter_signup_mail)
21
+ @element.content_by_name('mail_from').essence.update_attribute(:body, 'frank@dank.com')
22
+ @element.content_by_name('subject').essence.update_attribute(:body, 'Welcome, please confirm')
23
+ @element.content_by_name('text').essence.update_attribute(:body, 'Hello %{name}, please click %{link}')
24
+ @email = ContactsMailer.signup_mail(@contact, @page).deliver
25
+ end
26
+
27
+ it "should deliver to the contact's email address" do
28
+ @email.should deliver_to(@contact.email)
29
+ end
30
+
31
+ it "should have correct delivered from" do
32
+ @email.should deliver_from(@element.ingredient('mail_from'))
33
+ end
34
+
35
+ it "should contain a link to the confirmation link" do
36
+ url_regexp = Regexp.new(Regexp.escape(verify_contact_url(:token => @contact.email_sha1, :host => ActionMailer::Base.default_url_options[:host], :newsletter_ids => @contact.subscriptions.collect(&:newsletter_id))))
37
+ @email.should have_body_text(url_regexp)
38
+ end
39
+
40
+ it "should contain the correct greeting" do
41
+ @email.should have_body_text(/#{@contact.fullname}/)
42
+ end
43
+
44
+ it "should have the correct subject" do
45
+ @email.should have_subject(@element.ingredient('subject'))
46
+ end
47
+
48
+ end
49
+
50
+ describe '#signout_mail' do
51
+
52
+ before(:all) do
53
+ @element = @page.elements.find_by_name(:newsletter_signout_mail)
54
+ @element.content_by_name('mail_from').essence.update_attribute(:body, 'frank@dank.com')
55
+ @element.content_by_name('subject').essence.update_attribute(:body, 'Byebye, please confirm')
56
+ @element.content_by_name('text').essence.update_attribute(:body, 'Hello %{name}, please click %{link}')
57
+ @email = ContactsMailer.signout_mail(@contact, @page).deliver
58
+ end
59
+
60
+ it "should deliver to the contact's email address" do
61
+ @email.should deliver_to(@contact.email)
62
+ end
63
+
64
+ it "should have correct delivered from" do
65
+ @email.should deliver_from(@element.ingredient('mail_from'))
66
+ end
67
+
68
+ it "should contain a link to the confirmation link" do
69
+ @email.should have_body_text(/#{disable_contact_url(:token => @contact.email_sha1, :host => ActionMailer::Base.default_url_options[:host])}/)
70
+ end
71
+
72
+ it "should contain the correct greeting" do
73
+ @email.should have_body_text(/#{@contact.fullname}/)
74
+ end
75
+
76
+ it "should have the correct subject" do
77
+ @email.should have_subject(@element.ingredient('subject'))
78
+ end
79
+
80
+ end
81
+
82
+ after(:all) do
83
+ @language_root.destroy
84
+ @contact.destroy
85
+ end
86
+
87
+ end
88
88
  end
@@ -1,42 +1,42 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module AlchemyCrm
4
- describe MailingsMailer do
4
+ describe MailingsMailer do
5
5
 
6
- describe '#build' do
6
+ describe '#build' do
7
7
 
8
- before(:all) do
9
- @mailing = Mailing.create!(:name => 'Mailing', :subject => 'News Mailing', :additional_email_addresses => "jim@family.com, jon@doe.com, jane@family.com, \n", :newsletter => Newsletter.create!(:name => 'Newsletter', :layout => 'newsletter_layout_standard'))
10
- @mailing.deliveries.create!
11
- @element = @mailing.page.elements.first
12
- @element.content_by_name('text').essence.update_attribute(:body, "<h2>Hello World</h2>")
13
- @recipient = @mailing.recipients.first
14
- @language_root = Alchemy::Page.create!(:name => 'Language Root', :page_layout => 'standard', :language => Alchemy::Language.get_default, :parent_id => Alchemy::Page.root.id)
15
- @unsubscribe_page = Alchemy::Page.create!(:name => 'Unsubscribe Page', :page_layout => 'newsletter_signout', :parent_id => @language_root.id, :language => Alchemy::Language.get_default)
16
- @email = MailingsMailer.build(@mailing, @recipient, {:host => ActionMailer::Base.default_url_options[:host], :language_id => Alchemy::Language.get_default.id}).deliver
17
- end
8
+ before(:all) do
9
+ @mailing = Mailing.create!(:name => 'Mailing', :subject => 'News Mailing', :additional_email_addresses => "jim@family.com, jon@doe.com, jane@family.com, \n", :newsletter => Newsletter.create!(:name => 'Newsletter', :layout => 'newsletter_layout_standard'))
10
+ @mailing.deliveries.create!
11
+ @element = @mailing.page.elements.first
12
+ @element.content_by_name('text').essence.update_attribute(:body, "<h2>Hello World</h2>")
13
+ @recipient = @mailing.recipients.first
14
+ @language_root = Alchemy::Page.create!(:name => 'Language Root', :page_layout => 'standard', :language => Alchemy::Language.get_default, :parent_id => Alchemy::Page.root.id)
15
+ @unsubscribe_page = Alchemy::Page.create!(:name => 'Unsubscribe Page', :page_layout => 'newsletter_signout', :parent_id => @language_root.id, :language => Alchemy::Language.get_default)
16
+ @email = MailingsMailer.build(@mailing, @recipient, {:host => ActionMailer::Base.default_url_options[:host], :language_id => Alchemy::Language.get_default.id}).deliver
17
+ end
18
18
 
19
- it "should render the mailings body." do
20
- @email.should have_body_text(/#{Regexp.escape(@element.ingredient('text'))}/)
21
- end
19
+ it "should render the mailings body." do
20
+ @email.should have_body_text(/#{Regexp.escape(@element.ingredient('text'))}/)
21
+ end
22
22
 
23
- it "should render a plain text version of mailings body." do
24
- @email.text_part.should_not have_body_text(/<h2>/)
25
- end
23
+ it "should render a plain text version of mailings body." do
24
+ @email.text_part.should_not have_body_text(/<h2>/)
25
+ end
26
26
 
27
- it "should deliver to recipient's email." do
28
- @email.should deliver_to(@recipient.email)
29
- end
27
+ it "should deliver to recipient's email." do
28
+ @email.should deliver_to(@recipient.email)
29
+ end
30
30
 
31
- it "should have mailing's subject." do
32
- @email.should have_subject(@mailing.subject)
33
- end
31
+ it "should have mailing's subject." do
32
+ @email.should have_subject(@mailing.subject)
33
+ end
34
34
 
35
- after(:all) do
36
- @language_root.destroy
37
- end
35
+ after(:all) do
36
+ @language_root.destroy
37
+ end
38
38
 
39
- end
39
+ end
40
40
 
41
- end
41
+ end
42
42
  end
@@ -1,41 +1,41 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module AlchemyCrm
4
- describe ContactGroup do
4
+ describe ContactGroup do
5
5
 
6
- describe "#contacts" do
6
+ describe "#contacts" do
7
7
 
8
- before(:each) do
9
- @verified_contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :tag_list => 'father', :verified => true}, :as => :admin)
10
- @contact = Contact.create!({:email => 'jane@smith.com', :firstname => 'Jane', :lastname => 'Smith', :salutation => 'ms', :tag_list => 'mother'}, :as => :admin)
11
- @contact_group = ContactGroup.create!(:name => 'Family', :contact_tag_list => 'father, mother, son')
12
- end
8
+ before(:each) do
9
+ @verified_contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :tag_list => 'father', :verified => true}, :as => :admin)
10
+ @contact = Contact.create!({:email => 'jane@smith.com', :firstname => 'Jane', :lastname => 'Smith', :salutation => 'ms', :tag_list => 'mother'}, :as => :admin)
11
+ @contact_group = ContactGroup.create!(:name => 'Family', :contact_tag_list => 'father, mother, son')
12
+ end
13
13
 
14
- context "with filter" do
14
+ context "with filter" do
15
15
 
16
- before(:each) do
17
- @contact_group.filters.create!(:column => 'lastname', :operator => 'IS', :value => 'Doe', :contact_group => @contact_group)
18
- end
16
+ before(:each) do
17
+ @contact_group.filters.create!(:column => 'lastname', :operator => 'IS', :value => 'Doe', :contact_group => @contact_group)
18
+ end
19
19
 
20
- it "should return correct list of contacts" do
21
- @contact_group.contacts.collect(&:email).should == ["jon@doe.com"]
22
- end
20
+ it "should return correct list of contacts" do
21
+ @contact_group.contacts.collect(&:email).should == ["jon@doe.com"]
22
+ end
23
23
 
24
- end
24
+ end
25
25
 
26
- context "without filter" do
26
+ context "without filter" do
27
27
 
28
- before(:each) do
29
- @contact_group.filters.delete_all
30
- end
28
+ before(:each) do
29
+ @contact_group.filters.delete_all
30
+ end
31
31
 
32
- it "should return all contacts with tag" do
33
- @contact_group.contacts.collect(&:email).should == ["jon@doe.com", "jane@smith.com"]
34
- end
32
+ it "should return all contacts with tag" do
33
+ @contact_group.contacts.collect(&:email).should == ["jon@doe.com", "jane@smith.com"]
34
+ end
35
35
 
36
- end
36
+ end
37
37
 
38
- end
38
+ end
39
39
 
40
- end
40
+ end
41
41
  end
@@ -1,108 +1,108 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module AlchemyCrm
4
- describe Contact do
4
+ describe Contact do
5
5
 
6
- before(:all) do
7
- @contact = Contact.create!({:email => 'jon@doe.com', :title => 'Dr.', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :verified => true}, :as => :admin)
8
- end
6
+ before(:all) do
7
+ @contact = Contact.create!({:email => 'jon@doe.com', :title => 'Dr.', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :verified => true}, :as => :admin)
8
+ end
9
9
 
10
- describe '.create' do
10
+ describe '.create' do
11
11
 
12
- it "should set email_salt and email_sha1 for new records" do
13
- @contact.email_sha1.should_not be_nil
14
- @contact.email_salt.should_not be_nil
15
- end
12
+ it "should set email_salt and email_sha1 for new records" do
13
+ @contact.email_sha1.should_not be_nil
14
+ @contact.email_salt.should_not be_nil
15
+ end
16
16
 
17
- end
17
+ end
18
18
 
19
- describe '#save' do
19
+ describe '#save' do
20
20
 
21
- context "a contact with new email address" do
21
+ context "a contact with new email address" do
22
22
 
23
- before(:each) do
24
- @sha1 = @contact.email_sha1
25
- @salt = @contact.email_salt
26
- @contact.update_attributes!(:email => 'jane@doe.com')
27
- end
23
+ before(:each) do
24
+ @sha1 = @contact.email_sha1
25
+ @salt = @contact.email_salt
26
+ @contact.update_attributes!(:email => 'jane@doe.com')
27
+ end
28
28
 
29
- it "should update email_sha1" do
30
- @contact.email_sha1.should_not == @sha1
31
- end
29
+ it "should update email_sha1" do
30
+ @contact.email_sha1.should_not == @sha1
31
+ end
32
32
 
33
- it "should not update salt" do
34
- @contact.email_salt.should == @salt
35
- end
33
+ it "should not update salt" do
34
+ @contact.email_salt.should == @salt
35
+ end
36
36
 
37
- end
37
+ end
38
38
 
39
- context "a contact with same email address" do
39
+ context "a contact with same email address" do
40
40
 
41
- before(:each) do
42
- @sha1 = @contact.email_sha1
43
- @salt = @contact.email_salt
44
- @contact.update_attributes!(:firstname => 'jane')
45
- end
41
+ before(:each) do
42
+ @sha1 = @contact.email_sha1
43
+ @salt = @contact.email_salt
44
+ @contact.update_attributes!(:firstname => 'jane')
45
+ end
46
46
 
47
- it "should not update email_sha1" do
48
- @contact.email_sha1.should == @sha1
49
- end
47
+ it "should not update email_sha1" do
48
+ @contact.email_sha1.should == @sha1
49
+ end
50
50
 
51
- it "should not update salt" do
52
- @contact.email_salt.should == @salt
53
- end
51
+ it "should not update salt" do
52
+ @contact.email_salt.should == @salt
53
+ end
54
54
 
55
- end
55
+ end
56
56
 
57
- end
57
+ end
58
58
 
59
- describe '#interpolation_name_value' do
59
+ describe '#interpolation_name_value' do
60
60
 
61
- before(:each) do
62
- @contact.update_attributes!(:firstname => 'Jon')
63
- end
61
+ before(:each) do
62
+ @contact.update_attributes!(:firstname => 'Jon')
63
+ end
64
64
 
65
- context "not given a name_with_title value in the config" do
65
+ context "not given a name_with_title value in the config" do
66
66
 
67
- before(:each) do
68
- Config.stub!(:get).and_return(nil)
69
- end
67
+ before(:each) do
68
+ Config.stub!(:get).and_return(nil)
69
+ end
70
70
 
71
- it "should return the default value." do
72
- @contact.interpolation_name_value.should == "Mr Dr. Jon Doe"
73
- end
71
+ it "should return the default value." do
72
+ @contact.interpolation_name_value.should == "Mr Dr. Jon Doe"
73
+ end
74
74
 
75
- end
75
+ end
76
76
 
77
- context "given a valid method name in the config" do
77
+ context "given a valid method name in the config" do
78
78
 
79
- before(:each) do
80
- Config.stub!(:get).and_return('name_with_title')
81
- end
79
+ before(:each) do
80
+ Config.stub!(:get).and_return('name_with_title')
81
+ end
82
82
 
83
- it "should return the correct value." do
84
- @contact.interpolation_name_value.should == "Dr. Jon Doe"
85
- end
83
+ it "should return the correct value." do
84
+ @contact.interpolation_name_value.should == "Dr. Jon Doe"
85
+ end
86
86
 
87
- end
87
+ end
88
88
 
89
- context "given not a valid method name in the config" do
89
+ context "given not a valid method name in the config" do
90
90
 
91
- before(:each) do
92
- Config.stub!(:get).and_return('password')
93
- end
91
+ before(:each) do
92
+ Config.stub!(:get).and_return('password')
93
+ end
94
94
 
95
- it "should return the default value." do
96
- @contact.interpolation_name_value.should == "Mr Dr. Jon Doe"
97
- end
95
+ it "should return the default value." do
96
+ @contact.interpolation_name_value.should == "Mr Dr. Jon Doe"
97
+ end
98
98
 
99
- end
99
+ end
100
100
 
101
- end
101
+ end
102
102
 
103
- after(:all) do
104
- @contact.destroy
105
- end
103
+ after(:all) do
104
+ @contact.destroy
105
+ end
106
106
 
107
- end
107
+ end
108
108
  end