google_analytics_mailer 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.2, released 2013-09-26
2
+
3
+ * Removed blank params from generated urls
4
+
1
5
  ## 0.1.1, released 2013-08-23
2
6
 
3
7
  * Added license to gemspec
@@ -14,6 +14,8 @@ module GoogleAnalyticsMailer # :nodoc:
14
14
  params_to_add = controller.computed_analytics_params.with_indifferent_access
15
15
  # temporary override coming from with_google_analytics_params method
16
16
  params_to_add.merge!(@_override_ga_params) if @_override_ga_params.try(:any?)
17
+ # remove empty GA params
18
+ params_to_add.delete_if { |_, v| v.blank? }
17
19
  # if there are no parameters return super value
18
20
  if params_to_add.empty?
19
21
  super(original_url)
@@ -1,3 +1,3 @@
1
1
  module GoogleAnalyticsMailer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ # Mock helper used to test module methods
4
+ # @see http://stackoverflow.com/questions/5944278/overriding-method-by-another-defined-in-module
5
+ class MockHelper
6
+ # No op implementation of url_for
7
+ def url_for(url)
8
+ url
9
+ end
10
+
11
+ # Used by implementation
12
+ def controller
13
+ self
14
+ end
15
+
16
+ def computed_analytics_params
17
+ {}.with_indifferent_access
18
+ end
19
+ end
20
+
21
+ describe GoogleAnalyticsMailer::UrlFor do
22
+
23
+ let(:dummy_class) { Class.new(MockHelper) { include GoogleAnalyticsMailer::UrlFor } }
24
+ let(:subject) { dummy_class.new }
25
+
26
+ describe '#url_for' do
27
+
28
+ it 'should not include blank GA params' do
29
+ subject.stub(computed_analytics_params: {utm_campaign: nil})
30
+ subject.url_for('http://www.example.com').should_not include 'utm_campaign'
31
+ end
32
+
33
+ it 'should uri encode GA parameter values' do
34
+ subject.stub(computed_analytics_params: {utm_campaign: 'Foo Bar'})
35
+ subject.url_for('http://www.example.com').should include 'utm_campaign=Foo%20Bar'
36
+ end
37
+
38
+ end
39
+
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_analytics_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-23 00:00:00.000000000 Z
12
+ date: 2013-09-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -132,6 +132,7 @@ files:
132
132
  - lib/google_analytics_mailer/url_for.rb
133
133
  - lib/google_analytics_mailer/version.rb
134
134
  - spec/lib/google_analytics_mailer_spec.rb
135
+ - spec/lib/url_for_spec.rb
135
136
  - spec/spec_helper.rb
136
137
  - spec/support/views/user_mailer/welcome.html.erb
137
138
  - spec/support/views/user_mailer/welcome2.html.erb
@@ -164,6 +165,7 @@ summary: This gem provides automatic Google Analytics tagged links in ActionMail
164
165
  generated emails
165
166
  test_files:
166
167
  - spec/lib/google_analytics_mailer_spec.rb
168
+ - spec/lib/url_for_spec.rb
167
169
  - spec/spec_helper.rb
168
170
  - spec/support/views/user_mailer/welcome.html.erb
169
171
  - spec/support/views/user_mailer/welcome2.html.erb