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.
- data/Gemfile +10 -11
- data/alchemy_crm.gemspec +21 -21
- data/app/assets/javascripts/alchemy_crm/alchemy_crm.base.js +54 -54
- data/app/assets/stylesheets/alchemy_crm/base.css.scss +199 -199
- data/app/controllers/alchemy_crm/admin/base_controller.rb +5 -5
- data/app/controllers/alchemy_crm/admin/contact_groups_controller.rb +15 -15
- data/app/controllers/alchemy_crm/admin/contacts_controller.rb +95 -95
- data/app/controllers/alchemy_crm/admin/deliveries_controller.rb +66 -66
- data/app/controllers/alchemy_crm/admin/elements_controller_extension.rb +23 -23
- data/app/controllers/alchemy_crm/admin/mailings_controller.rb +44 -44
- data/app/controllers/alchemy_crm/admin/newsletters_controller.rb +16 -16
- data/app/controllers/alchemy_crm/admin/tags_controller.rb +60 -59
- data/app/controllers/alchemy_crm/base_controller.rb +3 -3
- data/app/controllers/alchemy_crm/contacts_controller.rb +88 -88
- data/app/controllers/alchemy_crm/mailings_controller.rb +16 -16
- data/app/controllers/alchemy_crm/recipients_controller.rb +30 -30
- data/app/controllers/alchemy_crm/subscriptions_controller.rb +54 -54
- data/app/helpers/alchemy/pages_helper_extension.rb +14 -14
- data/app/helpers/alchemy_crm/admin/base_helper.rb +8 -8
- data/app/helpers/alchemy_crm/mailings_helper.rb +175 -175
- data/app/mailers/alchemy_crm/bounce_receiver.rb +9 -9
- data/app/mailers/alchemy_crm/contacts_mailer.rb +21 -21
- data/app/mailers/alchemy_crm/mailings_mailer.rb +46 -46
- data/app/mailers/alchemy_crm/subscriptions_mailer.rb +12 -12
- data/app/models/alchemy/essence_element_teaser.rb +14 -14
- data/app/models/alchemy_crm/contact.rb +260 -260
- data/app/models/alchemy_crm/contact_group.rb +15 -15
- data/app/models/alchemy_crm/contact_group_filter.rb +17 -17
- data/app/models/alchemy_crm/delivery.rb +54 -54
- data/app/models/alchemy_crm/element_extension.rb +23 -23
- data/app/models/alchemy_crm/mailing.rb +90 -90
- data/app/models/alchemy_crm/newsletter.rb +33 -33
- data/app/models/alchemy_crm/reaction.rb +5 -5
- data/app/models/alchemy_crm/recipient.rb +46 -46
- data/app/models/alchemy_crm/subscription.rb +4 -4
- data/app/views/alchemy/admin/elements/fill.js.erb +11 -11
- data/app/views/alchemy/elements/_newsletter_article_view.html.erb +14 -14
- data/app/views/alchemy/elements/_newsletter_greeting_view.html.erb +9 -9
- data/app/views/alchemy/elements/_newsletter_signout_form_view.html.erb +18 -18
- data/app/views/alchemy/elements/_newsletter_signup_form_view.html.erb +62 -62
- data/app/views/alchemy/essences/_essence_element_teaser_editor.html.erb +29 -29
- data/app/views/alchemy/newsletter_layouts/_standard.html.erb +37 -37
- data/app/views/alchemy_crm/admin/contact_groups/_contact_group.html.erb +30 -30
- data/app/views/alchemy_crm/admin/contact_groups/_filter.html.erb +28 -28
- data/app/views/alchemy_crm/admin/contact_groups/_form.html.erb +45 -45
- data/app/views/alchemy_crm/admin/contact_groups/_tag.html.erb +4 -4
- data/app/views/alchemy_crm/admin/contact_groups/add_filter.js.erb +7 -7
- data/app/views/alchemy_crm/admin/contact_groups/index.html.erb +28 -28
- data/app/views/alchemy_crm/admin/contacts/_contact.html.erb +42 -42
- data/app/views/alchemy_crm/admin/contacts/_form.html.erb +76 -76
- data/app/views/alchemy_crm/admin/contacts/import.html.erb +27 -27
- data/app/views/alchemy_crm/admin/contacts/index.html.erb +39 -39
- data/app/views/alchemy_crm/admin/contacts/vcf_import_result.html.erb +24 -24
- data/app/views/alchemy_crm/admin/deliveries/_delivery.html.erb +30 -30
- data/app/views/alchemy_crm/admin/deliveries/_form.html.erb +61 -61
- data/app/views/alchemy_crm/admin/deliveries/_recipient.html.erb +36 -36
- data/app/views/alchemy_crm/admin/deliveries/index.html.erb +21 -21
- data/app/views/alchemy_crm/admin/deliveries/show.html.erb +61 -61
- data/app/views/alchemy_crm/admin/elements/teasables.html.erb +53 -53
- data/app/views/alchemy_crm/admin/mailings/_form.html.erb +41 -41
- data/app/views/alchemy_crm/admin/mailings/_mailing.html.erb +73 -73
- data/app/views/alchemy_crm/admin/mailings/edit_content.html.erb +170 -170
- data/app/views/alchemy_crm/admin/mailings/import_result.html.erb +18 -18
- data/app/views/alchemy_crm/admin/mailings/index.html.erb +25 -25
- data/app/views/alchemy_crm/admin/newsletters/_form.html.erb +52 -52
- data/app/views/alchemy_crm/admin/newsletters/_tag_with_radiobutton.html.erb +5 -5
- data/app/views/alchemy_crm/admin/newsletters/index.html.erb +29 -29
- data/app/views/alchemy_crm/admin/newsletters/new.html.erb +4 -4
- data/app/views/alchemy_crm/admin/tags/_radio_tag.html.erb +4 -4
- data/app/views/alchemy_crm/admin/tags/_tag.html.erb +30 -30
- data/app/views/alchemy_crm/admin/tags/edit.html.erb +32 -32
- data/app/views/alchemy_crm/admin/tags/index.html.erb +23 -23
- data/app/views/alchemy_crm/admin/tags/new.html.erb +14 -14
- data/app/views/alchemy_crm/contacts_mailer/signout_mail.html.erb +6 -6
- data/app/views/alchemy_crm/contacts_mailer/signout_mail.text.erb +2 -2
- data/app/views/alchemy_crm/contacts_mailer/signup_mail.html.erb +9 -9
- data/app/views/alchemy_crm/contacts_mailer/signup_mail.text.erb +2 -2
- data/app/views/alchemy_crm/mailings_mailer/verification_mail.html.erb +9 -9
- data/app/views/alchemy_crm/subscriptions/index.html.erb +4 -4
- data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.html.erb +25 -25
- data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.text.erb +2 -2
- data/app/views/csv_magic/import_errors.html.erb +23 -23
- data/app/views/csv_magic/mapper.html.erb +46 -46
- data/app/views/layouts/alchemy_crm/mailings.html.erb +177 -177
- data/config/initializers/assets.rb +2 -2
- data/config/locales/alchemy_crm.de.yml +1 -1
- data/config/locales/alchemy_crm.en.yml +1 -0
- data/config/locales/localized_country_select.de.rb +260 -260
- data/config/locales/localized_country_select.en.rb +274 -274
- data/config/routes.rb +67 -67
- data/db/migrate/20111104125306_remove_sent_mailing_pdf_id_from_sent_mailings.rb +1 -1
- data/db/migrate/20111124145923_namespace_alchemy_crm_models.rb +13 -13
- data/db/migrate/20120307160721_rename_alchemy_crm_recipients_sent_mailing_id.rb +3 -3
- data/db/migrate/20120320103412_add_indexes_to_alchemy_crm_sha1_columns.rb +3 -3
- data/db/migrate/20120327174301_add_more_indexes_to_alchemy_crm_tables.rb +10 -10
- data/lib/alchemy_crm.rb +15 -15
- data/lib/alchemy_crm/bounced_delivery.rb +38 -38
- data/lib/alchemy_crm/config.rb +25 -25
- data/lib/alchemy_crm/engine.rb +31 -31
- data/lib/alchemy_crm/i18n_helpers.rb +28 -28
- data/lib/alchemy_crm/newsletter_layout.rb +28 -28
- data/lib/alchemy_crm/seeder.rb +26 -26
- data/lib/alchemy_crm/version.rb +1 -1
- data/lib/generators/alchemy_crm/scaffold/files/newsletters.html.erb +19 -19
- data/lib/generators/alchemy_crm/scaffold/scaffold_generator.rb +2 -2
- data/lib/tasks/alchemy_crm.rake +22 -22
- data/lib/tasks/routes.rake +25 -25
- data/spec/config_spec.rb +24 -24
- data/spec/controllers/alchemy_crm/contacts_controller_spec.rb +147 -147
- data/spec/controllers/alchemy_crm/mailings_controller_spec.rb +62 -62
- data/spec/controllers/alchemy_crm/recipients_controller_spec.rb +109 -109
- data/spec/helpers/alchemy_crm/mailings_helper_spec.rb +165 -165
- data/spec/mailers/alchemy_crm/contacts_mailer_spec.rb +84 -84
- data/spec/mailers/alchemy_crm/mailings_mailer_spec.rb +29 -29
- data/spec/models/alchemy_crm/contact_group_spec.rb +25 -25
- data/spec/models/alchemy_crm/contact_spec.rb +71 -71
- data/spec/models/alchemy_crm/delivery_spec.rb +43 -39
- data/spec/models/alchemy_crm/mailing_spec.rb +46 -42
- data/spec/models/alchemy_crm/newsletter_spec.rb +29 -29
- data/spec/spec_helper.rb +36 -36
- metadata +6 -8
- data/rails/init.rb +0 -1
- data/recipes/alchemy-mailings-capistrano-tasks.rb +0 -12
@@ -1,89 +1,89 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module AlchemyCrm
|
4
|
-
|
4
|
+
describe MailingsController do
|
5
5
|
|
6
|
-
|
6
|
+
describe '#show' do
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
before(:each) do
|
9
|
+
@newsletter = Newsletter.create!(:name => 'Newsletter', :layout => 'newsletter_layout_standard')
|
10
|
+
@mailing = Mailing.create!(:name => 'Mailing', :newsletter => @newsletter)
|
11
|
+
end
|
12
12
|
|
13
|
-
|
13
|
+
context "receiving an id" do
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
before(:each) do
|
16
|
+
get :show, {:id => @mailing.id, :use_route => :alchemy_crm}
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
it "should have a recipient" do
|
20
|
+
assigns(:recipient).should_not be(nil)
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
it "should have a fake contact" do
|
24
|
+
assigns(:contact).email.should == Contact.fake.email
|
25
|
+
end
|
26
26
|
|
27
|
-
|
27
|
+
end
|
28
28
|
|
29
|
-
|
29
|
+
context "receiving a hash and email from recipient with contact" do
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
before(:each) do
|
32
|
+
@contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :verified => true}, :as => :admin)
|
33
|
+
@recipient = Recipient.create!(:email => 'foo@baz.org', :contact => @contact)
|
34
|
+
@delivery = Delivery.create!(:recipients => [@recipient], :mailing => @mailing)
|
35
|
+
get :show, {:m => @mailing.sha1, :r => @recipient.sha1, :use_route => :alchemy_crm}
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
it "should assign recipient" do
|
39
|
+
assigns(:recipient).should == @recipient
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
it "should assign contact from recipient" do
|
43
|
+
assigns(:contact).should == @contact
|
44
|
+
end
|
45
45
|
|
46
|
-
|
46
|
+
end
|
47
47
|
|
48
|
-
|
48
|
+
context "receiving a hash and email from recipient without contact" do
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
before(:each) do
|
51
|
+
@recipient = Recipient.create!(:email => 'foo@baz.org')
|
52
|
+
@delivery = Delivery.create!(:recipients => [@recipient], :mailing => @mailing)
|
53
|
+
get :show, {:m => @mailing.sha1, :r => @recipient.sha1, :use_route => :alchemy_crm}
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
it "should assign recipient" do
|
57
|
+
assigns(:recipient).should == @recipient
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
it "should assign new contact from recipients email" do
|
61
|
+
assigns(:contact).should be_a_new(Contact)
|
62
|
+
assigns(:contact).email.should == "foo@baz.org"
|
63
|
+
end
|
64
64
|
|
65
|
-
|
65
|
+
end
|
66
66
|
|
67
|
-
|
67
|
+
context "rendering" do
|
68
68
|
|
69
|
-
|
69
|
+
render_views
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
before(:each) do
|
72
|
+
@contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :verified => true}, :as => :admin)
|
73
|
+
@recipient = Recipient.create!(:email => 'foo@baz.org', :contact => @contact)
|
74
|
+
@delivery = Delivery.create!(:recipients => [@recipient], :mailing => @mailing)
|
75
|
+
@language_root = Alchemy::Page.create!(:name => 'Language Root', :page_layout => 'standard', :language => Alchemy::Language.get_default, :parent_id => Alchemy::Page.root.id)
|
76
|
+
@unsubscribe_page = Alchemy::Page.create!(:name => 'Unsubscribe Page', :page_layout => 'newsletter_signout', :parent_id => @language_root.id, :language => Alchemy::Language.get_default)
|
77
|
+
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
it "should render the view." do
|
80
|
+
lambda {
|
81
|
+
get :show, {:m => @mailing.sha1, :r => @recipient.sha1, :use_route => :alchemy_crm}
|
82
|
+
}.should_not raise_error
|
83
|
+
end
|
84
84
|
|
85
|
-
|
85
|
+
end
|
86
86
|
|
87
|
-
|
88
|
-
|
87
|
+
end
|
88
|
+
end
|
89
89
|
end
|
@@ -1,155 +1,155 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module AlchemyCrm
|
4
|
-
|
4
|
+
describe RecipientsController do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
before(:each) do
|
7
|
+
@recipient = Recipient.create!(:email => 'foo@baz.org')
|
8
|
+
end
|
9
9
|
|
10
|
-
|
10
|
+
describe '#reads' do
|
11
11
|
|
12
|
-
|
12
|
+
context "receiving a recipient hash" do
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
before(:each) do
|
15
|
+
get :reads, {:h => @recipient.sha1, :use_route => :alchemy_crm}
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
it "should record the read and read_at date." do
|
19
|
+
@recipient.reload
|
20
|
+
@recipient.read.should be_true
|
21
|
+
@recipient.read_at.should_not be_nil
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
it "should not render anything." do
|
25
|
+
response.code.should == "200"
|
26
|
+
response.body.should == " "
|
27
|
+
end
|
28
28
|
|
29
|
-
|
29
|
+
end
|
30
30
|
|
31
|
-
|
31
|
+
context "reading multiple times" do
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
it "should not record the reading any more." do
|
34
|
+
@recipient.update_attributes(:read => true)
|
35
|
+
get :reads, {:h => @recipient.sha1, :use_route => :alchemy_crm}
|
36
|
+
@recipient.read_at_changed?.should == false
|
37
|
+
end
|
38
38
|
|
39
|
-
|
39
|
+
end
|
40
40
|
|
41
|
-
|
41
|
+
context "not receiving a recipient hash" do
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
it "should not raise 404 / RecordNotFound error." do
|
44
|
+
lambda {
|
45
|
+
get :reads, {:use_route => :alchemy_crm}
|
46
|
+
}.should_not raise_error(ActiveRecord::RecordNotFound)
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
it "should not record any reading." do
|
50
|
+
get :reads, {:use_route => :alchemy_crm}
|
51
|
+
@recipient.reload
|
52
|
+
@recipient.read.should be_false
|
53
|
+
end
|
54
54
|
|
55
|
-
|
55
|
+
end
|
56
56
|
|
57
|
-
|
57
|
+
end
|
58
58
|
|
59
|
-
|
59
|
+
describe '#reacts' do
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
before(:each) do
|
62
|
+
Alchemy::PageLayout.add({"name" => 'standard', "elements" => ['headline']})
|
63
|
+
@language_root = Alchemy::Page.create!(:name => 'Language Root', :page_layout => 'standard', :parent_id => Alchemy::Page.root.id, :language => Alchemy::Language.get_default)
|
64
|
+
@page = Alchemy::Page.create!(:name => 'Page 1', :page_layout => 'standard', :parent_id => @language_root.id, :language => @language_root.language)
|
65
|
+
end
|
66
66
|
|
67
|
-
|
67
|
+
context "receiving a redirect url" do
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
before(:each) do
|
70
|
+
get :reacts, {:h => @recipient.sha1, :r => "http://google.de", :use_route => 'alchemy_crm'}
|
71
|
+
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
it "should record the url as reaction for recipient." do
|
74
|
+
@recipient.reactions.collect(&:url).should include("http://google.de")
|
75
|
+
end
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
it "should redirect to url." do
|
78
|
+
response.code.should == "302"
|
79
|
+
response.should redirect_to('http://google.de')
|
80
|
+
end
|
81
81
|
|
82
|
-
|
82
|
+
end
|
83
83
|
|
84
|
-
|
84
|
+
context "receiving a page id" do
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
before(:each) do
|
87
|
+
get :reacts, {:h => @recipient.sha1, :page_id => @page.id, :use_route => 'alchemy_crm'}
|
88
|
+
end
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
90
|
+
it "should record the page id as reaction for recipient." do
|
91
|
+
@recipient.reactions.collect(&:page_id).should include(@page.id)
|
92
|
+
end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
it "should redirect to page path." do
|
95
|
+
response.code.should == "302"
|
96
|
+
response.should redirect_to('/page-1')
|
97
|
+
end
|
98
98
|
|
99
|
-
|
99
|
+
end
|
100
100
|
|
101
|
-
|
101
|
+
context "not receiving a page id" do
|
102
102
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
it "should raise 404 / RecordNotFound." do
|
104
|
+
lambda {
|
105
|
+
get :reacts, {:h => @recipient.sha1, :use_route => 'alchemy_crm'}
|
106
|
+
}.should raise_error(ActiveRecord::RecordNotFound)
|
107
|
+
end
|
108
108
|
|
109
|
-
|
109
|
+
end
|
110
110
|
|
111
|
-
|
111
|
+
context "receiving page id and element id" do
|
112
112
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
113
|
+
before(:each) do
|
114
|
+
Alchemy::Element.stub!(:descriptions).and_return([{"name" => "headline"}])
|
115
|
+
@element = Alchemy::Element.create!(:name => 'headline', :page => @page)
|
116
|
+
get :reacts, {:h => @recipient.sha1, :page_id => @page.id, :element_id => @element.id, :use_route => 'alchemy_crm'}
|
117
|
+
end
|
118
118
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
it "should record the page id and element id as reaction for recipient." do
|
120
|
+
@recipient.reactions.collect(&:page_id).should include(@page.id)
|
121
|
+
@recipient.reactions.collect(&:element_id).should include(@element.id)
|
122
|
+
end
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
it "should redirect to page path with element dom id as anchor." do
|
125
|
+
response.code.should == "302"
|
126
|
+
response.should redirect_to("/page-1##{@element.dom_id}")
|
127
|
+
end
|
128
128
|
|
129
|
-
|
129
|
+
end
|
130
130
|
|
131
|
-
|
131
|
+
context "not receiving a recipient id" do
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
133
|
+
it "should not raise 404 / RecordNotFound." do
|
134
|
+
lambda {
|
135
|
+
get :reacts, {:r => "http://google.de", :use_route => 'alchemy_crm'}
|
136
|
+
}.should_not raise_error(ActiveRecord::RecordNotFound)
|
137
|
+
end
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
it "should not record any reactions." do
|
140
|
+
get :reacts, {:r => "http://google.de", :use_route => 'alchemy_crm'}
|
141
|
+
@recipient.reactions.should be_empty
|
142
|
+
end
|
143
143
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
it "should redirect." do
|
145
|
+
get :reacts, {:r => "http://google.de", :use_route => 'alchemy_crm'}
|
146
|
+
response.code.should == "302"
|
147
|
+
response.should redirect_to('http://google.de')
|
148
|
+
end
|
149
149
|
|
150
|
-
|
150
|
+
end
|
151
151
|
|
152
|
-
|
152
|
+
end
|
153
153
|
|
154
|
-
|
154
|
+
end
|
155
155
|
end
|
@@ -1,169 +1,169 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module AlchemyCrm
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
4
|
+
describe MailingsHelper do
|
5
|
+
|
6
|
+
include AlchemyCrm::Engine.routes.url_helpers
|
7
|
+
|
8
|
+
let(:recipient) { mock_model('Recipient', :email => 'foo@bar.org', :sha1 => 'kjhgfdfgh') }
|
9
|
+
|
10
|
+
describe '#render_newsletter_layout' do
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@page = Alchemy::Page.new(:name => 'Mailing page', :page_layout => 'newsletter_layout_standard')
|
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
|
+
@mailing = mock_model('Mailing', :name => 'News 01/2012')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should render the newsletter layout" do
|
20
|
+
helper.stub!(:render_elements).and_return("")
|
21
|
+
helper.stub!(:configuration).and_return(true)
|
22
|
+
helper.stub!(:current_server).and_return('http://example.com')
|
23
|
+
helper.stub!(:current_language).and_return(mock_model('Language', :name => 'English'))
|
24
|
+
helper.render_newsletter_layout.should =~ /<h1>Newsletter/
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should render the newsletter layout in plain text" do
|
28
|
+
helper.stub!(:render_elements).and_return("")
|
29
|
+
helper.stub!(:configuration).and_return(true)
|
30
|
+
helper.request.format = :text
|
31
|
+
helper.render_newsletter_layout(:format => :text).should_not =~ /<h1>Newsletter/
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#render_tracking_image' do
|
37
|
+
it "should render a tracking image with recipient_reads_url as source." do
|
38
|
+
helper.stub!(:current_host).and_return('example.com')
|
39
|
+
@recipient = recipient
|
40
|
+
helper.render_tracking_image.should match /<img.+src=.#{recipient_reads_url(:h => recipient.sha1, :host => 'example.com')}/
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#link_to_unsubscribe_page' do
|
45
|
+
|
46
|
+
before(:each) do
|
47
|
+
unsubscribe_page = mock_model('Page', {:urlname => 'unsubscribe'})
|
48
|
+
Alchemy::Page.stub!(:find_by_page_layout).and_return(unsubscribe_page)
|
49
|
+
helper.stub!(:multi_language?).and_return(false)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should render a link to the unsubscribe page." do
|
53
|
+
helper.stub!(:current_host).and_return('example.com')
|
54
|
+
helper.link_to_unsubscribe_page.should match /<a.+href=.+example.com\/unsubscribe/
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#read_in_browser_notice' do
|
60
|
+
it "should render a notice with a link to read the mailing in a browser." do
|
61
|
+
@recipient = recipient
|
62
|
+
@mailing = mock_model('Mailing', :sha1 => 'lkjhvghfcdfjgkh')
|
63
|
+
helper.stub!(:current_host).and_return('example.com')
|
64
|
+
helper.read_in_browser_notice.should match /If the newsletter does not displays correctly, click <a.+href=.#{show_mailing_url(:m => @mailing.sha1, :r => @recipient.sha1, :host => 'example.com')}/
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#image_from_server_tag' do
|
69
|
+
it "should render an image with full url to server." do
|
70
|
+
Rails.application.config.assets.prefix = 'images'
|
71
|
+
helper.stub!(:current_server).and_return('https://example.com')
|
72
|
+
helper.image_from_server_tag('logo.png').should match /<img.+src=.https:\/\/example.com\/images\/logo.png/
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#tracked_link_tag' do
|
77
|
+
it "should render a link with tracking url." do
|
78
|
+
@recipient = recipient
|
79
|
+
helper.stub!(:current_host).and_return('example.com')
|
80
|
+
helper.tracked_link_tag('read more', '/de/my-article', :style => 'color: black').should match /<a.+href=.#{Regexp.escape(recipient_reacts_url({:h => recipient.sha1, :r => '/de/my-article', :host => 'example.com'}))}.+style=.color: black.+read more/
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#current_host' do
|
85
|
+
it "should return the host from request." do
|
86
|
+
helper.stub!(:request).and_return(OpenStruct.new({:host => 'example.com'}))
|
87
|
+
helper.current_host.should match /^example.com$/
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should return the host from options[:host] if no request is present." do
|
91
|
+
helper.stub!(:request).and_return(nil)
|
92
|
+
helper.instance_variable_set('@options', {:host => 'example.com'})
|
93
|
+
helper.current_host.should match /^example.com$/
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#current_server' do
|
98
|
+
|
99
|
+
context "if no request given" do
|
100
|
+
it "should return the full server url from options." do
|
101
|
+
helper.stub!(:request).and_return(nil)
|
102
|
+
helper.instance_variable_set('@options', {
|
103
|
+
:port => 80,
|
104
|
+
:host => 'example.com'
|
105
|
+
})
|
106
|
+
helper.current_server.should match /^http:\/\/example.com$/
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "if request given" do
|
111
|
+
it "should return the full server url from request." do
|
112
|
+
helper.current_server.should match /^http:\/\/test.host$/
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context "given a port different from 80 with options present" do
|
117
|
+
it "should return the full server url with port." do
|
118
|
+
helper.stub!(:request).and_return(nil)
|
119
|
+
helper.instance_variable_set('@options', {
|
120
|
+
:port => 3000,
|
121
|
+
:host => 'localhost'
|
122
|
+
})
|
123
|
+
helper.current_server.should match /^http:\/\/localhost:3000$/
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context "given port 80 with options present" do
|
128
|
+
it "should return the full server url without port." do
|
129
|
+
helper.stub!(:request).and_return(nil)
|
130
|
+
helper.instance_variable_set('@options', {
|
131
|
+
:port => 80,
|
132
|
+
:host => 'example.com'
|
133
|
+
})
|
134
|
+
helper.current_server.should match /^http:\/\/example.com$/
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "given a port different from 80 with request present" do
|
139
|
+
it "should return the full server url with port." do
|
140
|
+
helper.stub!(:request).and_return(OpenStruct.new({:host => 'localhost', :port => 3000, :protocol => 'http://'}))
|
141
|
+
helper.current_server.should match /^http:\/\/localhost:3000$/
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context "given port 80 with request present" do
|
146
|
+
it "should return the full server url without port." do
|
147
|
+
helper.current_server.should match /^http:\/\/test.host$/
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#current_language' do
|
154
|
+
it "should return the language from session[:language_id]." do
|
155
|
+
helper.current_language.should be_an_instance_of(Alchemy::Language)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should return the language from options[:language_id] if no session is present." do
|
159
|
+
helper.instance_variable_set('@options', {:language_id => Alchemy::Language.get_default.id})
|
160
|
+
helper.current_language.should be_an_instance_of(Alchemy::Language)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should return the default language if no session or options[:language_id] is present." do
|
164
|
+
helper.current_language.should be_an_instance_of(Alchemy::Language)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
169
|
end
|