shareprogress 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gems +3 -0
- data/.gitignore +2 -0
- data/LICENSE +21 -0
- data/README.md +10 -0
- data/Rakefile +3 -0
- data/lib/shareprogress/filters/new_button.rb +47 -0
- data/lib/shareprogress/filters/new_email_variants.rb +26 -0
- data/lib/shareprogress/filters/new_facebook_variants.rb +25 -0
- data/lib/shareprogress/filters/new_twitter_variants.rb +21 -0
- data/lib/shareprogress.rb +143 -0
- data/shareprogress.gemspec +17 -0
- data/test/create_button_test.rb +314 -0
- data/test/create_email_button_test.rb +208 -0
- data/test/create_facebook_button_test.rb +226 -0
- data/test/create_twitter_button_test.rb +192 -0
- metadata +101 -0
@@ -0,0 +1,208 @@
|
|
1
|
+
require "cutest"
|
2
|
+
require_relative "../lib/shareprogress"
|
3
|
+
|
4
|
+
# Monkeypath the communication with ShareProgress
|
5
|
+
module ShareProgress
|
6
|
+
module Button
|
7
|
+
def self.request(method, payload)
|
8
|
+
return {
|
9
|
+
"success"=>true,
|
10
|
+
"response"=>[{
|
11
|
+
"id"=>12136,
|
12
|
+
"page_url"=>"http://sumofus.org/",
|
13
|
+
"page_title"=>"My Email button name",
|
14
|
+
"button_template"=>"sp_em_large",
|
15
|
+
"share_button_html"=>"<div class='sp_12136 sp_em_large' ></div>",
|
16
|
+
"found_snippet"=>false,
|
17
|
+
"is_active"=>false,
|
18
|
+
"variants"=>{
|
19
|
+
"facebook"=>[{
|
20
|
+
"id"=>48542,
|
21
|
+
"facebook_title"=>"SumOfUs",
|
22
|
+
"facebook_description"=>"SumOfUs is a global movement of "\
|
23
|
+
"consumers, investors, and workers all around the world, standing "\
|
24
|
+
"together to hold corporations accountable for their actions and "\
|
25
|
+
"forge a new, sustainable and just path for our global economy. "\
|
26
|
+
"It's not going to be fast or easy. B",
|
27
|
+
"facebook_thumbnail"=>"http://sumofus.org/wp-content/themes/"\
|
28
|
+
"pgm/img/default-facebook.jpg"}],
|
29
|
+
"email"=>[{
|
30
|
+
"id"=>48539,
|
31
|
+
"email_subject"=>"Email subject 1!",
|
32
|
+
"email_body"=>"Email body 1 {LINK}"}, {
|
33
|
+
"id"=>48540,
|
34
|
+
"email_subject"=>"Email subject 2!",
|
35
|
+
"email_body"=>"Email body 2 {LINK}"}, {
|
36
|
+
"id"=>48541,
|
37
|
+
"email_subject"=>"Email subject 3!",
|
38
|
+
"email_body"=>"Email body 3 {LINK}"}],
|
39
|
+
"twitter"=>[{
|
40
|
+
"id"=>48543,
|
41
|
+
"twitter_message"=>"SumOfUs {LINK}"}]},
|
42
|
+
"advanced_options"=>{
|
43
|
+
"automatic_traffic_routing"=>true,
|
44
|
+
"buttons_optimize_actions"=>true,
|
45
|
+
"customize_params"=>{
|
46
|
+
"param"=>"param_to_use",
|
47
|
+
"e"=>"email_source",
|
48
|
+
"f"=>"facebook_source",
|
49
|
+
"t"=>"twitter_source",
|
50
|
+
"o"=>"dark_social_source"},
|
51
|
+
"id_pass"=>{
|
52
|
+
"id"=>"id",
|
53
|
+
"passed"=>"referrer_id"}}}],
|
54
|
+
"message"=>nil
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
setup do
|
61
|
+
{
|
62
|
+
"key" => "123456",
|
63
|
+
"page_url" => "http://sumofus.org/",
|
64
|
+
"page_title" => "My Email button name",
|
65
|
+
"auto_fill" => true,
|
66
|
+
"button_template" => "sp_em_large",
|
67
|
+
"variants" => {
|
68
|
+
"email" => [
|
69
|
+
{"email_subject" => "Email subject 1!",
|
70
|
+
"email_body" => "Email body 1 {LINK}"},
|
71
|
+
{"email_subject" => "Email subject 2!",
|
72
|
+
"email_body" => "Email body 2 {LINK}"},
|
73
|
+
{"email_subject" => "Email subject 3!",
|
74
|
+
"email_body" => "Email body 3 {LINK}"}
|
75
|
+
]
|
76
|
+
},
|
77
|
+
"advanced_options" => {
|
78
|
+
"automatic_traffic_routing" => true,
|
79
|
+
"buttons_optimize_actions" => true,
|
80
|
+
"customize_params" => {
|
81
|
+
"param" => "param_to_use",
|
82
|
+
"e" => "email_source",
|
83
|
+
"f" => "facebook_source",
|
84
|
+
"t" => "twitter_source",
|
85
|
+
"o" => "dark_social_source"
|
86
|
+
},
|
87
|
+
"id_pass" => {
|
88
|
+
"id" => "id",
|
89
|
+
"passed" => "referrer_id"
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
scope do
|
96
|
+
# all
|
97
|
+
test "create email button successfully" do |data|
|
98
|
+
result = ShareProgress::Button.create(data)
|
99
|
+
|
100
|
+
expected_result = {
|
101
|
+
"id"=>12136,
|
102
|
+
"page_url"=>"http://sumofus.org/",
|
103
|
+
"page_title"=>"My Email button name",
|
104
|
+
"button_template"=>"sp_em_large",
|
105
|
+
"share_button_html"=>"<div class='sp_12136 sp_em_large' ></div>",
|
106
|
+
"found_snippet"=>false,
|
107
|
+
"is_active"=>false,
|
108
|
+
"variants"=>{
|
109
|
+
"facebook"=>[{
|
110
|
+
"id"=>48542,
|
111
|
+
"facebook_title"=>"SumOfUs",
|
112
|
+
"facebook_description"=>"SumOfUs is a global movement of "\
|
113
|
+
"consumers, investors, and workers all around the world, "\
|
114
|
+
"standing together to hold corporations accountable for their "\
|
115
|
+
"actions and forge a new, sustainable and just path for our "\
|
116
|
+
"global economy. It's not going to be fast or easy. B",
|
117
|
+
"facebook_thumbnail"=>"http://sumofus.org/wp-content/themes/pgm/"\
|
118
|
+
"img/default-facebook.jpg"}],
|
119
|
+
"email"=>[{
|
120
|
+
"id"=>48539,
|
121
|
+
"email_subject"=>"Email subject 1!",
|
122
|
+
"email_body"=>"Email body 1 {LINK}"}, {
|
123
|
+
"id"=>48540,
|
124
|
+
"email_subject"=>"Email subject 2!",
|
125
|
+
"email_body"=>"Email body 2 {LINK}"}, {
|
126
|
+
"id"=>48541,
|
127
|
+
"email_subject"=>"Email subject 3!",
|
128
|
+
"email_body"=>"Email body 3 {LINK}"}],
|
129
|
+
"twitter"=>[{
|
130
|
+
"id"=>48543,
|
131
|
+
"twitter_message"=>"SumOfUs {LINK}"}]},
|
132
|
+
"advanced_options"=>{
|
133
|
+
"automatic_traffic_routing"=>true,
|
134
|
+
"buttons_optimize_actions"=>true,
|
135
|
+
"customize_params"=>{
|
136
|
+
"param"=>"param_to_use",
|
137
|
+
"e"=>"email_source",
|
138
|
+
"f"=>"facebook_source",
|
139
|
+
"t"=>"twitter_source",
|
140
|
+
"o"=>"dark_social_source"},
|
141
|
+
"id_pass"=>{
|
142
|
+
"id"=>"id",
|
143
|
+
"passed"=>"referrer_id"}}
|
144
|
+
}
|
145
|
+
|
146
|
+
assert result == expected_result
|
147
|
+
end
|
148
|
+
|
149
|
+
test "create email button with wrong button_template" do |data|
|
150
|
+
data["button_template"] = "sp_tw_large"
|
151
|
+
|
152
|
+
result = ShareProgress::Button.create(data)
|
153
|
+
|
154
|
+
expected_result = {:button_template=>[:not_valid]}
|
155
|
+
|
156
|
+
assert result == expected_result
|
157
|
+
end
|
158
|
+
|
159
|
+
test "create email button with nil email_subject" do |data|
|
160
|
+
data["variants"]["email"][0]["email_subject"] = nil
|
161
|
+
|
162
|
+
result = ShareProgress::Button.create(data)
|
163
|
+
|
164
|
+
expected_result = {:email_subject=>[:nil]}
|
165
|
+
|
166
|
+
assert result == expected_result
|
167
|
+
end
|
168
|
+
|
169
|
+
test "create email button with empty email_subject" do |data|
|
170
|
+
data["variants"]["email"][0]["email_subject"] = ""
|
171
|
+
|
172
|
+
result = ShareProgress::Button.create(data)
|
173
|
+
|
174
|
+
expected_result = {:email_subject=>[:empty]}
|
175
|
+
|
176
|
+
assert result == expected_result
|
177
|
+
end
|
178
|
+
|
179
|
+
test "create email button with nil email_body" do |data|
|
180
|
+
data["variants"]["email"][0]["email_body"] = nil
|
181
|
+
|
182
|
+
result = ShareProgress::Button.create(data)
|
183
|
+
|
184
|
+
expected_result = {:email_body=>[:nil]}
|
185
|
+
|
186
|
+
assert result == expected_result
|
187
|
+
end
|
188
|
+
|
189
|
+
test "create email button with empty email_body" do |data|
|
190
|
+
data["variants"]["email"][0]["email_body"] = ""
|
191
|
+
|
192
|
+
result = ShareProgress::Button.create(data)
|
193
|
+
|
194
|
+
expected_result = {:email_body=>[:empty]}
|
195
|
+
|
196
|
+
assert result == expected_result
|
197
|
+
end
|
198
|
+
|
199
|
+
test "create email button with {LINK} not included in email_body" do |data|
|
200
|
+
data["variants"]["email"][0]["email_body"] = "This is a content with no link"
|
201
|
+
|
202
|
+
result = ShareProgress::Button.create(data)
|
203
|
+
|
204
|
+
expected_result = {:email_body=>[:link_not_included]}
|
205
|
+
|
206
|
+
assert result == expected_result
|
207
|
+
end
|
208
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
require "cutest"
|
2
|
+
require_relative "../lib/shareprogress"
|
3
|
+
|
4
|
+
# Monkeypath the communication with ShareProgress
|
5
|
+
module ShareProgress
|
6
|
+
module Button
|
7
|
+
def self.request(method, payload)
|
8
|
+
return {
|
9
|
+
"success"=>true,
|
10
|
+
"response"=>[{
|
11
|
+
"id"=>12154,
|
12
|
+
"page_url"=>"http://sumofus.org/",
|
13
|
+
"page_title"=>"My Facebook button name",
|
14
|
+
"button_template"=>"sp_fb_large",
|
15
|
+
"share_button_html"=>"<div class='sp_12154 sp_fb_large' ></div>",
|
16
|
+
"found_snippet"=>false,
|
17
|
+
"is_active"=>false,
|
18
|
+
"variants"=>{
|
19
|
+
"facebook"=>[{
|
20
|
+
"id"=>48643,
|
21
|
+
"facebook_title"=>"Facebook Title 1",
|
22
|
+
"facebook_description"=>"Facebook Description 1",
|
23
|
+
"facebook_thumbnail"=>"/path/to/images/facebook_1.jpg"}, {
|
24
|
+
"id"=>48644,
|
25
|
+
"facebook_title"=>"Facebook Title 2",
|
26
|
+
"facebook_description"=>"Facebook Description 2",
|
27
|
+
"facebook_thumbnail"=>"/path/to/images/facebook_2.jpg"}, {
|
28
|
+
"id"=>48645,
|
29
|
+
"facebook_title"=>"Facebook Title 3",
|
30
|
+
"facebook_description"=>"Facebook Description 3",
|
31
|
+
"facebook_thumbnail"=>"/path/to/images/facebook_3.jpg"}],
|
32
|
+
"email"=>[{
|
33
|
+
"id"=>48647,
|
34
|
+
"email_subject"=>"SumOfUs",
|
35
|
+
"email_body"=>"SumOfUs is a global movement of consumers, "\
|
36
|
+
"investors, and workers all around the world, standing "\
|
37
|
+
"together to hold corporations accountable for their "\
|
38
|
+
"actions and forge a new, sustainable and just path for "\
|
39
|
+
"our global economy. It's not going to be fast or easy. "\
|
40
|
+
"But if enough of us come together, we can make a real "\
|
41
|
+
"difference.\n{LINK}"}],
|
42
|
+
"twitter"=>[{
|
43
|
+
"id"=>48646,
|
44
|
+
"twitter_message"=>"SumOfUs {LINK}"}]},
|
45
|
+
"advanced_options"=>{
|
46
|
+
"automatic_traffic_routing"=>true,
|
47
|
+
"buttons_optimize_actions"=>true,
|
48
|
+
"customize_params"=>{
|
49
|
+
"param"=>"param_to_use",
|
50
|
+
"e"=>"email_source",
|
51
|
+
"f"=>"facebook_source",
|
52
|
+
"t"=>"twitter_source",
|
53
|
+
"o"=>"dark_social_source"},
|
54
|
+
"id_pass"=>{
|
55
|
+
"id"=>"id",
|
56
|
+
"passed"=>"referrer_id"}}}],
|
57
|
+
"message"=>nil}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
setup do
|
63
|
+
{
|
64
|
+
"key" => "123456",
|
65
|
+
"page_url" => "http://sumofus.org/",
|
66
|
+
"page_title" => "My Facebook button name",
|
67
|
+
"auto_fill" => true,
|
68
|
+
"button_template" => "sp_fb_large",
|
69
|
+
"variants" => {
|
70
|
+
"facebook" => [
|
71
|
+
{"facebook_title" => "Facebook Title 1",
|
72
|
+
"facebook_description" => "Facebook Description 1",
|
73
|
+
"facebook_thumbnail" => "/path/to/images/facebook_1.jpg"},
|
74
|
+
{"facebook_title" => "Facebook Title 2",
|
75
|
+
"facebook_description" => "Facebook Description 2",
|
76
|
+
"facebook_thumbnail" => "/path/to/images/facebook_2.jpg"},
|
77
|
+
{"facebook_title" => "Facebook Title 3",
|
78
|
+
"facebook_description" => "Facebook Description 3",
|
79
|
+
"facebook_thumbnail" => "/path/to/images/facebook_3.jpg"}
|
80
|
+
]
|
81
|
+
},
|
82
|
+
"advanced_options" => {
|
83
|
+
"automatic_traffic_routing" => true,
|
84
|
+
"buttons_optimize_actions" => true,
|
85
|
+
"customize_params" => {
|
86
|
+
"param" => "param_to_use",
|
87
|
+
"e" => "email_source",
|
88
|
+
"f" => "facebook_source",
|
89
|
+
"t" => "twitter_source",
|
90
|
+
"o" => "dark_social_source"
|
91
|
+
},
|
92
|
+
"id_pass" => {
|
93
|
+
"id" => "id",
|
94
|
+
"passed" => "referrer_id"
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
scope do
|
101
|
+
# all
|
102
|
+
test "create facebook button successfully" do |data|
|
103
|
+
result = ShareProgress::Button.create(data)
|
104
|
+
|
105
|
+
expected_result = {
|
106
|
+
"id"=>12154,
|
107
|
+
"page_url"=>"http://sumofus.org/",
|
108
|
+
"page_title"=>"My Facebook button name",
|
109
|
+
"button_template"=>"sp_fb_large",
|
110
|
+
"share_button_html"=>"<div class='sp_12154 sp_fb_large' ></div>",
|
111
|
+
"found_snippet"=>false,
|
112
|
+
"is_active"=>false,
|
113
|
+
"variants"=>{
|
114
|
+
"facebook"=>[{
|
115
|
+
"id"=>48643,
|
116
|
+
"facebook_title"=>"Facebook Title 1",
|
117
|
+
"facebook_description"=>"Facebook Description 1",
|
118
|
+
"facebook_thumbnail"=>"/path/to/images/facebook_1.jpg"}, {
|
119
|
+
"id"=>48644,
|
120
|
+
"facebook_title"=>"Facebook Title 2",
|
121
|
+
"facebook_description"=>"Facebook Description 2",
|
122
|
+
"facebook_thumbnail"=>"/path/to/images/facebook_2.jpg"}, {
|
123
|
+
"id"=>48645,
|
124
|
+
"facebook_title"=>"Facebook Title 3",
|
125
|
+
"facebook_description"=>"Facebook Description 3",
|
126
|
+
"facebook_thumbnail"=>"/path/to/images/facebook_3.jpg"}],
|
127
|
+
"email"=>[{
|
128
|
+
"id"=>48647,
|
129
|
+
"email_subject"=>"SumOfUs",
|
130
|
+
"email_body"=>"SumOfUs is a global movement of consumers, "\
|
131
|
+
"investors, and workers all around the world, standing "\
|
132
|
+
"together to hold corporations accountable for their "\
|
133
|
+
"actions and forge a new, sustainable and just path for "\
|
134
|
+
"our global economy. It's not going to be fast or easy. "\
|
135
|
+
"But if enough of us come together, we can make a real "\
|
136
|
+
"difference.\n{LINK}"}],
|
137
|
+
"twitter"=>[{
|
138
|
+
"id"=>48646,
|
139
|
+
"twitter_message"=>"SumOfUs {LINK}"}]},
|
140
|
+
"advanced_options"=>{
|
141
|
+
"automatic_traffic_routing"=>true,
|
142
|
+
"buttons_optimize_actions"=>true,
|
143
|
+
"customize_params"=>{
|
144
|
+
"param"=>"param_to_use",
|
145
|
+
"e"=>"email_source",
|
146
|
+
"f"=>"facebook_source",
|
147
|
+
"t"=>"twitter_source",
|
148
|
+
"o"=>"dark_social_source"},
|
149
|
+
"id_pass"=>{
|
150
|
+
"id"=>"id",
|
151
|
+
"passed"=>"referrer_id"}}
|
152
|
+
}
|
153
|
+
|
154
|
+
assert result == expected_result
|
155
|
+
end
|
156
|
+
|
157
|
+
test "create facebook button with wrong button_template" do |data|
|
158
|
+
data["button_template"] = "sp_em_small"
|
159
|
+
|
160
|
+
result = ShareProgress::Button.create(data)
|
161
|
+
|
162
|
+
expected_result = {:button_template=>[:not_valid]}
|
163
|
+
|
164
|
+
assert result == expected_result
|
165
|
+
end
|
166
|
+
|
167
|
+
test "create facebook button with nil facebook_title" do |data|
|
168
|
+
data["variants"]["facebook"][0]["facebook_title"] = nil
|
169
|
+
|
170
|
+
result = ShareProgress::Button.create(data)
|
171
|
+
|
172
|
+
expected_result = {:facebook_title=>[:nil]}
|
173
|
+
|
174
|
+
assert result == expected_result
|
175
|
+
end
|
176
|
+
|
177
|
+
test "create facebook button with empty facebook_title" do |data|
|
178
|
+
data["variants"]["facebook"][0]["facebook_title"] = ""
|
179
|
+
|
180
|
+
result = ShareProgress::Button.create(data)
|
181
|
+
|
182
|
+
expected_result = {:facebook_title=>[:empty]}
|
183
|
+
|
184
|
+
assert result == expected_result
|
185
|
+
end
|
186
|
+
|
187
|
+
test "create facebook button with nil facebook_description" do |data|
|
188
|
+
data["variants"]["facebook"][0]["facebook_description"] = nil
|
189
|
+
|
190
|
+
result = ShareProgress::Button.create(data)
|
191
|
+
|
192
|
+
expected_result = {:facebook_description=>[:nil]}
|
193
|
+
|
194
|
+
assert result == expected_result
|
195
|
+
end
|
196
|
+
|
197
|
+
test "create facebook button with empty facebook_description" do |data|
|
198
|
+
data["variants"]["facebook"][0]["facebook_description"] = ""
|
199
|
+
|
200
|
+
result = ShareProgress::Button.create(data)
|
201
|
+
|
202
|
+
expected_result = {:facebook_description=>[:empty]}
|
203
|
+
|
204
|
+
assert result == expected_result
|
205
|
+
end
|
206
|
+
|
207
|
+
test "create facebook button with nil facebook_thumbnail" do |data|
|
208
|
+
data["variants"]["facebook"][0]["facebook_thumbnail"] = nil
|
209
|
+
|
210
|
+
result = ShareProgress::Button.create(data)
|
211
|
+
|
212
|
+
expected_result = {:facebook_thumbnail=>[:nil]}
|
213
|
+
|
214
|
+
assert result == expected_result
|
215
|
+
end
|
216
|
+
|
217
|
+
test "create facebook button with empty facebook_thumbnail" do |data|
|
218
|
+
data["variants"]["facebook"][0]["facebook_thumbnail"] = ""
|
219
|
+
|
220
|
+
result = ShareProgress::Button.create(data)
|
221
|
+
|
222
|
+
expected_result = {:facebook_thumbnail=>[:empty]}
|
223
|
+
|
224
|
+
assert result == expected_result
|
225
|
+
end
|
226
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
require "cutest"
|
2
|
+
require_relative "../lib/shareprogress"
|
3
|
+
|
4
|
+
# Monkeypath the communication with ShareProgress
|
5
|
+
module ShareProgress
|
6
|
+
module Button
|
7
|
+
def self.request(method, payload)
|
8
|
+
return {
|
9
|
+
"success"=>true,
|
10
|
+
"response"=>[{
|
11
|
+
"id"=>12152,
|
12
|
+
"page_url"=>"http://sumofus.org/",
|
13
|
+
"page_title"=>"My Twitter button name",
|
14
|
+
"button_template"=>"sp_tw_large",
|
15
|
+
"share_button_html"=>"<div class='sp_12152 sp_tw_large' ></div>",
|
16
|
+
"found_snippet"=>false,
|
17
|
+
"is_active"=>false,
|
18
|
+
"variants"=>{
|
19
|
+
"facebook"=>[{
|
20
|
+
"id"=>48616,
|
21
|
+
"facebook_title"=>"SumOfUs",
|
22
|
+
"facebook_description"=>"SumOfUs is a global movement of "\
|
23
|
+
"consumers, investors, and workers all around the world, "\
|
24
|
+
"standing together to hold corporations accountable for "\
|
25
|
+
"their actions and forge a new, sustainable and just path "\
|
26
|
+
"for our global economy. It's not going to be fast or easy. B",
|
27
|
+
"facebook_thumbnail"=>"http://sumofus.org/wp-content/themes/pgm/"\
|
28
|
+
"img/default-facebook.jpg"}],
|
29
|
+
"email"=>[{
|
30
|
+
"id"=>48617,
|
31
|
+
"email_subject"=>"SumOfUs",
|
32
|
+
"email_body"=>"SumOfUs is a global movement of consumers, "\
|
33
|
+
"investors, and workers all around the world, standing together "\
|
34
|
+
"to hold corporations accountable for their actions and forge a "\
|
35
|
+
"new, sustainable and just path for our global economy. It's "\
|
36
|
+
"not going to be fast or easy. But if enough of us come "\
|
37
|
+
"together, we can make a real difference.\n{LINK}"}],
|
38
|
+
"twitter"=>[{
|
39
|
+
"id"=>48613,
|
40
|
+
"twitter_message"=>"Twitter message 1 {LINK}"}, {
|
41
|
+
"id"=>48614,
|
42
|
+
"twitter_message"=>"Twitter message 2 {LINK}"}, {
|
43
|
+
"id"=>48615,
|
44
|
+
"twitter_message"=>"Twitter message 3 {LINK}"}]},
|
45
|
+
"advanced_options"=>{
|
46
|
+
"automatic_traffic_routing"=>true,
|
47
|
+
"buttons_optimize_actions"=>true,
|
48
|
+
"customize_params"=>{
|
49
|
+
"param"=>"param_to_use",
|
50
|
+
"e"=>"email_source",
|
51
|
+
"f"=>"facebook_source",
|
52
|
+
"t"=>"twitter_source",
|
53
|
+
"o"=>"dark_social_source"},
|
54
|
+
"id_pass"=>{
|
55
|
+
"id"=>"id",
|
56
|
+
"passed"=>"referrer_id"}}}],
|
57
|
+
"message"=>nil
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
setup do
|
64
|
+
{
|
65
|
+
"key" => "123456",
|
66
|
+
"page_url" => "http://sumofus.org/",
|
67
|
+
"page_title" => "My Twitter button name",
|
68
|
+
"auto_fill" => true,
|
69
|
+
"button_template" => "sp_tw_large",
|
70
|
+
"variants" => {
|
71
|
+
"twitter" => [
|
72
|
+
{"twitter_message" => "Twitter message 1 {LINK}"},
|
73
|
+
{"twitter_message" => "Twitter message 2 {LINK}"},
|
74
|
+
{"twitter_message" => "Twitter message 3 {LINK}"}
|
75
|
+
]
|
76
|
+
},
|
77
|
+
"advanced_options" => {
|
78
|
+
"automatic_traffic_routing" => true,
|
79
|
+
"buttons_optimize_actions" => true,
|
80
|
+
"customize_params" => {
|
81
|
+
"param" => "param_to_use",
|
82
|
+
"e" => "email_source",
|
83
|
+
"f" => "facebook_source",
|
84
|
+
"t" => "twitter_source",
|
85
|
+
"o" => "dark_social_source"
|
86
|
+
},
|
87
|
+
"id_pass" => {
|
88
|
+
"id" => "id",
|
89
|
+
"passed" => "referrer_id"
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
scope do
|
96
|
+
# all
|
97
|
+
test "create twitter button successfully" do |data|
|
98
|
+
result = ShareProgress::Button.create(data)
|
99
|
+
|
100
|
+
expected_result = {
|
101
|
+
"id"=>12152,
|
102
|
+
"page_url"=>"http://sumofus.org/",
|
103
|
+
"page_title"=>"My Twitter button name",
|
104
|
+
"button_template"=>"sp_tw_large",
|
105
|
+
"share_button_html"=>"<div class='sp_12152 sp_tw_large' ></div>",
|
106
|
+
"found_snippet"=>false,
|
107
|
+
"is_active"=>false,
|
108
|
+
"variants"=>{
|
109
|
+
"facebook"=>[{
|
110
|
+
"id"=>48616,
|
111
|
+
"facebook_title"=>"SumOfUs",
|
112
|
+
"facebook_description"=>"SumOfUs is a global movement of "\
|
113
|
+
"consumers, investors, and workers all around the world, "\
|
114
|
+
"standing together to hold corporations accountable for their "\
|
115
|
+
"actions and forge a new, sustainable and just path for our "\
|
116
|
+
"global economy. It's not going to be fast or easy. B",
|
117
|
+
"facebook_thumbnail"=>"http://sumofus.org/wp-content/themes/pgm/"\
|
118
|
+
"img/default-facebook.jpg"}],
|
119
|
+
"email"=>[{
|
120
|
+
"id"=>48617,
|
121
|
+
"email_subject"=>"SumOfUs",
|
122
|
+
"email_body"=>"SumOfUs is a global movement of consumers, "\
|
123
|
+
"investors, and workers all around the world, standing together "\
|
124
|
+
"to hold corporations accountable for their actions and forge "\
|
125
|
+
"a new, sustainable and just path for our global economy. It's "\
|
126
|
+
"not going to be fast or easy. But if enough of us come "\
|
127
|
+
"together, we can make a real difference.\n{LINK}"}],
|
128
|
+
"twitter"=>[{
|
129
|
+
"id"=>48613,
|
130
|
+
"twitter_message"=>"Twitter message 1 {LINK}"}, {
|
131
|
+
"id"=>48614,
|
132
|
+
"twitter_message"=>"Twitter message 2 {LINK}"}, {
|
133
|
+
"id"=>48615,
|
134
|
+
"twitter_message"=>"Twitter message 3 {LINK}"}]},
|
135
|
+
"advanced_options"=>{
|
136
|
+
"automatic_traffic_routing"=>true,
|
137
|
+
"buttons_optimize_actions"=>true,
|
138
|
+
"customize_params"=>{
|
139
|
+
"param"=>"param_to_use",
|
140
|
+
"e"=>"email_source",
|
141
|
+
"f"=>"facebook_source",
|
142
|
+
"t"=>"twitter_source",
|
143
|
+
"o"=>"dark_social_source"},
|
144
|
+
"id_pass"=>{
|
145
|
+
"id"=>"id",
|
146
|
+
"passed"=>"referrer_id"}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
assert result == expected_result
|
151
|
+
end
|
152
|
+
|
153
|
+
test "create twitter button with wrong button_template" do |data|
|
154
|
+
data["button_template"] = "sp_fb_small"
|
155
|
+
|
156
|
+
result = ShareProgress::Button.create(data)
|
157
|
+
|
158
|
+
expected_result = {:button_template=>[:not_valid]}
|
159
|
+
|
160
|
+
assert result == expected_result
|
161
|
+
end
|
162
|
+
|
163
|
+
test "create twitter button with nil twitter_message" do |data|
|
164
|
+
data["variants"]["twitter"][0]["twitter_message"] = nil
|
165
|
+
|
166
|
+
result = ShareProgress::Button.create(data)
|
167
|
+
|
168
|
+
expected_result = {:twitter_message=>[:nil]}
|
169
|
+
|
170
|
+
assert result == expected_result
|
171
|
+
end
|
172
|
+
|
173
|
+
test "create twitter button with empty twitter_message" do |data|
|
174
|
+
data["variants"]["twitter"][0]["twitter_message"] = ""
|
175
|
+
|
176
|
+
result = ShareProgress::Button.create(data)
|
177
|
+
|
178
|
+
expected_result = {:twitter_message=>[:empty]}
|
179
|
+
|
180
|
+
assert result == expected_result
|
181
|
+
end
|
182
|
+
|
183
|
+
test "create twitter button with {LINK} not included in twitter_message" do |data|
|
184
|
+
data["variants"]["twitter"][0]["twitter_message"] = "This is a content with no link"
|
185
|
+
|
186
|
+
result = ShareProgress::Button.create(data)
|
187
|
+
|
188
|
+
expected_result = {:twitter_message=>[:link_not_included]}
|
189
|
+
|
190
|
+
assert result == expected_result
|
191
|
+
end
|
192
|
+
end
|