spree_pinterest 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,10 @@
1
+ # 0.2.1
2
+
3
+ * Make sure `media` URL param is always an absoute URL
4
+
1
5
  # 0.2.0
2
6
 
3
- * Always use product_url when pinning
7
+ * Always use `product_url` when pinning
4
8
 
5
9
  # 0.1.1
6
10
 
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'rspec', :version => 2, :cli => "--format Fuubar --fail-fast" do
4
+ guard 'rspec', :version => 2, :cli => "--format Fuubar" do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
6
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
7
  watch('spec/spec_helper.rb') { "spec" }
@@ -4,7 +4,7 @@ module Spree
4
4
  return if product.images.empty?
5
5
 
6
6
  url = escape spree.product_url(product)
7
- media = escape product.images.first.attachment.url
7
+ media = escape absolute_image_url(product.images.first.attachment.url)
8
8
  description = escape product.name
9
9
 
10
10
  link_to("Pin It",
@@ -18,5 +18,11 @@ module Spree
18
18
  def escape(string)
19
19
  URI.escape string, /[^#{URI::PATTERN::UNRESERVED}]/
20
20
  end
21
+
22
+ def absolute_image_url(url)
23
+ return url if url.starts_with? "http"
24
+
25
+ request.protocol + request.host + url
26
+ end
21
27
  end
22
28
  end
@@ -1,3 +1,3 @@
1
1
  module SpreePinterest
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -20,14 +20,35 @@ module Spree
20
20
  end
21
21
 
22
22
  describe "href" do
23
- let(:expected_output) do
24
- image = product.images.first
25
- "http://pinterest.com/pin/create/button/?url=#{escape(spree.product_url(product, :host => "test.host"))}&media=#{escape(image.attachment.url)}&description=#{escape(product.name)}"
23
+ context "when image attachment url is a relative url" do
24
+ before do
25
+ product.images.first.stub_chain(:attachment, :url).and_return("/path/to/image.png")
26
+ end
27
+
28
+ let(:expected_output) do
29
+ image = product.images.first
30
+ "http://pinterest.com/pin/create/button/?url=#{escape(spree.product_url(product, :host => "test.host"))}&media=#{escape("http://test.host#{image.attachment.url}")}&description=#{escape(product.name)}"
31
+ end
32
+
33
+ subject { Nokogiri::HTML(output).xpath("//a/@href").text }
34
+
35
+ it { should == expected_output }
26
36
  end
27
37
 
28
- subject { Nokogiri::HTML(output).xpath("//a/@href").text }
38
+ context "when image attachment url is an absolute url" do
39
+ before do
40
+ product.images.first.stub_chain(:attachment, :url).and_return("http://test.host/path/to/image.png")
41
+ end
29
42
 
30
- it { should == expected_output }
43
+ let(:expected_output) do
44
+ image = product.images.first
45
+ "http://pinterest.com/pin/create/button/?url=#{escape(spree.product_url(product, :host => "test.host"))}&media=#{escape("http://test.host#{image.attachment.url}")}&description=#{escape(product.name)}"
46
+ end
47
+
48
+ subject { Nokogiri::HTML(output).xpath("//a/@href").text }
49
+
50
+ it { should == expected_output }
51
+ end
31
52
 
32
53
  def escape(string)
33
54
  URI.escape string, /[^#{URI::PATTERN::UNRESERVED}]/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_pinterest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
16
- requirement: &70100608233560 !ruby/object:Gem::Requirement
16
+ requirement: &70114289412260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70100608233560
24
+ version_requirements: *70114289412260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: capybara
27
- requirement: &70100608228740 !ruby/object:Gem::Requirement
27
+ requirement: &70114289411760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.1
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70100608228740
35
+ version_requirements: *70114289411760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: factory_girl
38
- requirement: &70100608227720 !ruby/object:Gem::Requirement
38
+ requirement: &70114289411380 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70100608227720
46
+ version_requirements: *70114289411380
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ffaker
49
- requirement: &70100608227020 !ruby/object:Gem::Requirement
49
+ requirement: &70114289410780 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70100608227020
57
+ version_requirements: *70114289410780
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec-rails
60
- requirement: &70100608226500 !ruby/object:Gem::Requirement
60
+ requirement: &70114289409980 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '2.7'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70100608226500
68
+ version_requirements: *70114289409980
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
- requirement: &70100608225820 !ruby/object:Gem::Requirement
71
+ requirement: &70114289409240 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70100608225820
79
+ version_requirements: *70114289409240
80
80
  description: This extension provides a Pinterest "Pin it" button for your Spree product
81
81
  images.
82
82
  email: chad@genuitytech.com