sage_one 0.0.1 → 0.0.2

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.
data/History.txt ADDED
@@ -0,0 +1,7 @@
1
+ == 0.0.2 2013-03-27
2
+
3
+ * Follow HTTP Redirects.
4
+
5
+ == 0.0.1
6
+
7
+ * Initial release. Query sales invoices only.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Sage One [![Build Status](https://secure.travis-ci.org/customersure/sage_one.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/7b1e86c3d9e3583a684d326a97ba06d0.png)][gemnasium]
1
+ # Sage One [![Build Status](https://secure.travis-ci.org/customersure/sage_one.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/customersure/sage_one.png)][gemnasium]
2
2
  Faraday-based Ruby wrapper for the Sage One API
3
3
 
4
4
  [travis]: http://travis-ci.org/customersure/sage_one
@@ -34,6 +34,8 @@ module SageOne
34
34
  conn.use FaradayMiddleware::ParseJson
35
35
  end
36
36
 
37
+ conn.use FaradayMiddleware::FollowRedirects, limit: 1
38
+
37
39
  faraday_config_block.call(conn) if faraday_config_block
38
40
 
39
41
  conn.adapter(adapter)
@@ -1,3 +1,3 @@
1
1
  module SageOne
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/sage_one.gemspec CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.add_dependency 'addressable', '~>2.3'
6
6
  s.add_dependency 'faraday', '~>0.8'
7
7
  s.add_dependency 'faraday_middleware', '~> 0.9'
8
- s.add_dependency 'hashie', '~>1.2'
8
+ s.add_dependency 'hashie', '~>2.0'
9
9
  s.add_dependency 'multi_json', '~> 1.4'
10
10
 
11
11
  s.add_development_dependency 'json'
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe SageOne::Connection do
4
4
 
5
5
  let(:client) { SageOne.new }
6
- let(:basic_middleware) { %w(FaradayMiddleware::EncodeJson FaradayMiddleware::OAuth2 FaradayMiddleware::RaiseSageOneException) }
6
+ let(:basic_middleware) { %w(FaradayMiddleware::EncodeJson FaradayMiddleware::OAuth2 FaradayMiddleware::RaiseSageOneException FaradayMiddleware::FollowRedirects) }
7
7
  let(:non_raw_middleware) { %w(FaradayMiddleware::Mashify FaradayMiddleware::ParseJson) }
8
8
 
9
9
  it "returns a Faraday" do
@@ -15,7 +15,7 @@ describe SageOne::OAuth do
15
15
 
16
16
  stub_post("https://app.sageone.com/oauth/token/").
17
17
  with(:body => "{\"client_id\":\"CLIENT_ID\",\"client_secret\":\"CLIENT_SECRET\",\"grant_type\":\"authorization_code\",\"code\":\"uuddlrlr\",\"redirect_uri\":\"http://www.example.com/endpoint\"}",
18
- :headers => {'Accept'=>'application/json; charset=utf-8', 'Content-Type'=>'application/json', 'User-Agent'=>'SageOne Ruby Gem 0.0.1'}).
18
+ :headers => {'Accept'=>'application/json; charset=utf-8', 'Content-Type'=>'application/json'}).
19
19
  to_return(:body => fixture("oauth/oauth_token.json"))
20
20
 
21
21
  expect(client.get_access_token('uuddlrlr', 'http://www.example.com/endpoint').access_token).to eq('IguLPAK5VPvDSw3z4SjrkhHTyRXgnnqAPzt1mLUk')
@@ -68,6 +68,20 @@ describe SageOne::Request do
68
68
  a_get('sales_invoices').with(headers: { "Host" => 'CustomerHost' }).should have_been_made.once
69
69
  end
70
70
 
71
+ context 'being redirected' do
72
+ before do
73
+ stub_get('http://www.example.com/')
74
+ stub_request(:get, sage_url('sales_invoices'))
75
+ .to_return(body: '<!doctype html><html><head><title>hello</title></head><body><p>Word up.</p></body></html>',
76
+ status: 301,
77
+ headers: { 'Location' => 'http://www.example.com/' } )
78
+ end
79
+ it 'follows redirects (before it tries to parse the html body with a json parser)' do
80
+ client.get('sales_invoices')
81
+ a_get('http://www.example.com/').should have_been_made
82
+ end
83
+ end
84
+
71
85
  describe "response body" do
72
86
  context 'raw requested' do
73
87
  it "returns a faraday response" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sage_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-05 00:00:00.000000000 Z
13
+ date: 2013-03-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -67,7 +67,7 @@ dependencies:
67
67
  requirements:
68
68
  - - ~>
69
69
  - !ruby/object:Gem::Version
70
- version: '1.2'
70
+ version: '2.0'
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
@@ -75,7 +75,7 @@ dependencies:
75
75
  requirements:
76
76
  - - ~>
77
77
  - !ruby/object:Gem::Version
78
- version: '1.2'
78
+ version: '2.0'
79
79
  - !ruby/object:Gem::Dependency
80
80
  name: multi_json
81
81
  requirement: !ruby/object:Gem::Requirement
@@ -208,6 +208,7 @@ files:
208
208
  - .travis.yml
209
209
  - .yardopts
210
210
  - Gemfile
211
+ - History.txt
211
212
  - LICENSE
212
213
  - README.md
213
214
  - Rakefile
@@ -265,6 +266,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
266
  - - ! '>='
266
267
  - !ruby/object:Gem::Version
267
268
  version: '0'
269
+ segments:
270
+ - 0
271
+ hash: -2226741955563997097
268
272
  required_rubygems_version: !ruby/object:Gem::Requirement
269
273
  none: false
270
274
  requirements: