qbwc 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5bbaec3ca34a9a960128b6933f41fc78682d8ba4
4
- data.tar.gz: 7738ce71948875a6ea4a44753eddcfa37528ac64
3
+ metadata.gz: 3ab957ed6ecd97a44a5e2469092553102ae0adcf
4
+ data.tar.gz: 8391e13ebcc4a9a91c25590519993a446e1ba189
5
5
  SHA512:
6
- metadata.gz: e8c027bfc0527d79c5b6bb2a5e1c19f68ef7be4ea90a4d0e39a3b111c62a12ac57ef601dac756f0e951887e4de53955a4b681bf5881b9b5e4e66c374c2cf7a0f
7
- data.tar.gz: e52f3419dcc33fe1212600038f90586604603953a3c5a07795f8598e9fe55e8ffbc0018dc6fb18f8ea7ebfe72266a09087a174b081cc88a1025cc3a00fe69120
6
+ metadata.gz: 12dda6d0e3f59b48b26e85199fdd3ead7b74e2e38d78f22392f5b6b662d505083a1498ad71acc2c94518c14a6866dd7f3ed744c46bc95189642572b97940940f
7
+ data.tar.gz: b23152610874a9065f64d7d0bac9d12aadcfc1a0a2b7094858ae4d5c6f70dfa369964c28aaaba4b7c6f27dd3daffd26b52ad3dbf4d4726d9746b4c3f02365086
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ Gemfile.lock
3
3
  pkg
4
4
  .ruby-gemset
5
5
  .ruby-version
6
+ gemfiles/*.lock
@@ -1,8 +1,13 @@
1
1
  language: ruby
2
+
2
3
  rvm:
3
- - 1.9
4
- - 2.0
5
- - 2.1
6
4
  - 2.2
5
+ - 2.3.5 # https://github.com/travis-ci/travis-ci/issues/5361
6
+ - 2.4.2
7
+ gemfile:
8
+ - gemfiles/rails_5.1.gemfile
9
+ - gemfiles/rails_5.0.gemfile
7
10
  before_install:
8
11
  - gem update bundler
12
+
13
+ script: "bundle exec rake test"
@@ -0,0 +1,10 @@
1
+ appraise "rails-5.0" do
2
+ # At least 5.0.1 due to test failures - https://github.com/rails/rails/pull/25950
3
+ gem "actionpack", "~> 5.0.1"
4
+ gem "actionview", "~> 5.0.1"
5
+ end
6
+
7
+ appraise "rails-5.1" do
8
+ gem "actionpack", "~> 5.1.1"
9
+ gem "actionview", "~> 5.1.1"
10
+ end
@@ -1,6 +1,20 @@
1
1
 
2
2
  # Change Log
3
3
 
4
+ ## [1.1.0](https://github.com/qbwc/qbwc/releases/tag/v1.1.0) (2016-03-02)
5
+ [Full Changelog](https://github.com/qbwc/qbwc/compare/1.0.0...1.1.0)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Support Rails 5. [\#100](https://github.com/qbwc/qbwc/pull/100) ([rchekaluk](https://github.com/rchekaluk)) [\#117](https://github.com/qbwc/qbwc/pull/117) ([lostapathy](https://github.com/lostapathy))
10
+ - Clarify documentation regarding top-level tag in response hash. [\#91](https://github.com/qbwc/qbwc/pull/91) ([steintr](https://github.com/steintr))
11
+ - Fix Rails 5 deprecations. [\#97](https://github.com/qbwc/qbwc/pull/97) ([nicholejeannine](https://github.com/nicholejeannine))
12
+
13
+ **New features:**
14
+
15
+ - Log qbxml_response closer to the top of \#process_response. [\#90](https://github.com/qbwc/qbwc/pull/90) ([steintr](https://github.com/steintr))
16
+
17
+
4
18
  ## [1.0.0](https://github.com/qbwc/qbwc/releases/tag/v1.0.0) (2016-03-02)
5
19
  [Full Changelog](https://github.com/qbwc/qbwc/compare/0.1.0...1.0.0)
6
20
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in qbwc.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -72,12 +72,12 @@ To create a job (e.g. from `rails console` or wherever):
72
72
 
73
73
  ```ruby
74
74
  require 'qbwc'
75
- QBWC.add_job(:list_customers, true, '', CustomerTestWorker)
75
+ QBWC.add_job(:list_customers, true, 'C:\\QuickBooks\\Oceanic.QBW', CustomerTestWorker)
76
76
  ```
77
77
 
78
78
  * The first argument is a unique name for the job. You can use this later to disable or delete the job.
79
79
  * The second argument indicates whether the job is initially enabled.
80
- * The third argument specifies the path to the QuickBooks company file this job affects. An empty string will make the job run against any company file.
80
+ * The third argument specifies the path to the QuickBooks company file this job affects.
81
81
  * The fourth argument is your worker class. See the next section for a description of workers.
82
82
 
83
83
  Your job will be persisted in your database and will remain active and run every time QuickBooks Web Connector runs an update. If you don't want this to happen, you can have have your job disable or delete itself after completion. For example:
@@ -133,7 +133,7 @@ end
133
133
  ```
134
134
 
135
135
 
136
- Use the [Onscreen Reference for Intuit Software Development Kits](https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html) (use Format: qbXML) to see request and response formats to use in your jobs. Use underscored, lowercased versions of all tags (e.g. `customer_query_rq`, not `CustomerQueryRq`).
136
+ Use the [Onscreen Reference for Intuit Software Development Kits](https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html) (use Format: qbXML) to see request and response formats to use in your jobs. Use underscored, lowercased versions of all tags (e.g. `customer_query_rq`, not `CustomerQueryRq`). Note that while requests include the top-level tag (e.g. `customer_query_rq`), the response hash passed to `QBWC::Worker#handle_response` does not include a corresponding top-level tag such as `customer_query_rs` (despite it being in the actual QBXML and shown in the OSR).
137
137
 
138
138
  ### Defining requests outside of a worker ###
139
139
 
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'appraisal'
2
3
 
3
4
  Bundler::GemHelper.install_tasks
4
5
 
@@ -6,4 +7,9 @@ require 'rake/testtask'
6
7
  Rake::TestTask.new do |t|
7
8
  t.pattern = 'test/**/*_test.rb'
8
9
  end
9
- task :default => :test
10
+
11
+ task :default => :all
12
+
13
+ task :all do |_t|
14
+ exec('bundle exec appraisal install && bundle exec rake appraisal test')
15
+ end
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 5.0.1"
6
+ gem "actionview", "~> 5.0.1"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 5.1.1"
6
+ gem "actionview", "~> 5.1.1"
7
+
8
+ gemspec path: "../"
@@ -1,4 +1,4 @@
1
- class ChangeRequestIndex < ActiveRecord::Migration
1
+ class ChangeRequestIndex < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  change_column :qbwc_jobs, :request_index, :text, null: true, default: nil
4
4
  end
@@ -1,4 +1,4 @@
1
- class CreateQbwcJobs < ActiveRecord::Migration
1
+ class CreateQbwcJobs < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :qbwc_jobs, :force => true do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateQbwcSessions < ActiveRecord::Migration
1
+ class CreateQbwcSessions < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :qbwc_sessions, :force => true do |t|
4
4
  t.string :ticket
@@ -8,7 +8,7 @@ class CreateQbwcSessions < ActiveRecord::Migration
8
8
  t.string :current_job
9
9
  t.string :iterator_id
10
10
  t.string :error, :limit => 1000
11
- t.string :pending_jobs, :limit => 1000, :null => false, :default => ''
11
+ t.text :pending_jobs, :null => false, :default => ''
12
12
 
13
13
  t.timestamps :null => false
14
14
  end
@@ -1,4 +1,4 @@
1
- class IndexQbwcJobs < ActiveRecord::Migration
1
+ class IndexQbwcJobs < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  add_index :qbwc_jobs, :name, unique: true
4
4
  add_index :qbwc_jobs, :company, length: 150
@@ -1,4 +1,4 @@
1
- class SessionPendingJobsText < ActiveRecord::Migration
1
+ class SessionPendingJobsText < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  change_column_default(:qbwc_sessions, :pending_jobs, nil)
4
4
  change_column :qbwc_sessions, :pending_jobs, :text, :limit => 1000, :null => false
@@ -9,10 +9,10 @@ module QBWC
9
9
 
10
10
  def self.included(base)
11
11
  base.class_eval do
12
- include WashOut::SOAP
13
- skip_before_filter :_parse_soap_parameters, :_authenticate_wsse, :_map_soap_parameters, :only => :qwc
14
- before_filter :get_session, :except => [:qwc, :authenticate, :_generate_wsdl]
15
- after_filter :save_session, :except => [:qwc, :authenticate, :_generate_wsdl, :close_connection, :connection_error]
12
+ soap_service
13
+ skip_before_action :_authenticate_wsse, :_map_soap_parameters, :only => :qwc
14
+ before_action :get_session, :except => [:qwc, :authenticate, :_generate_wsdl]
15
+ after_action :save_session, :except => [:qwc, :authenticate, :_generate_wsdl, :close_connection, :connection_error]
16
16
 
17
17
  # wash_out changed the format of app/views/wash_with_soap/rpc/response.builder in commit
18
18
  # https://github.com/inossidabile/wash_out/commit/24a77f4a3d874562732c6e8c3a30e8defafea7cb
@@ -77,7 +77,7 @@ SB
77
77
  <AppURL>#{qbwc_action_url(:only_path => false)}</AppURL>
78
78
  <AppDescription>Quickbooks integration</AppDescription>
79
79
  <AppSupport>#{QBWC.support_site_url || root_url(:protocol => 'https://')}</AppSupport>
80
- <UserName>#{@username || QBWC.username}</UserName>
80
+ <UserName>#{QBWC.username}</UserName>
81
81
  <OwnerID>#{QBWC.owner_id}</OwnerID>
82
82
  <FileID>{#{file_id}}</FileID>
83
83
  <QBType>QBFS</QBType>
@@ -85,7 +85,7 @@ SB
85
85
  #{scheduler_block}
86
86
  </QBWCXML>
87
87
  QWC
88
- send_data qwc, :filename => "#{@filename || Rails.application.class.parent_name}.qwc", :content_type => 'application/x-qwc'
88
+ send_data qwc, :filename => "#{Rails.application.class.parent_name}.qwc", :content_type => 'application/x-qwc'
89
89
  end
90
90
 
91
91
  class StringArray < WashOut::Type
@@ -162,7 +162,7 @@ QWC
162
162
  end
163
163
 
164
164
  def app_name
165
- "#{Rails.application.class.parent_name} #{Rails.env} #{@app_name_suffix}"
165
+ "#{Rails.application.class.parent_name} #{Rails.env}"
166
166
  end
167
167
 
168
168
  def file_id
@@ -23,10 +23,10 @@ class QBWC::Job
23
23
 
24
24
  def process_response(qbxml_response, response, session, advance)
25
25
  QBWC.logger.info "Processing response."
26
+ QBWC.logger.info "Job '#{name}' received response: '#{qbxml_response}'." if QBWC.log_requests_and_responses
26
27
  request_list = requests(session)
27
28
  completed_request = request_list[request_index(session)] if request_list
28
29
  advance_next_request(session) if advance
29
- QBWC.logger.info "Job '#{name}' received response: '#{qbxml_response}'." if QBWC.log_requests_and_responses
30
30
  worker.handle_response(response, session, self, completed_request, data)
31
31
  end
32
32
 
@@ -1,3 +1,3 @@
1
1
  module QBWC
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -22,18 +22,20 @@ Gem::Specification.new do |s|
22
22
  "README.md"
23
23
  ]
24
24
 
25
+ s.required_ruby_version = '>= 2.2.2'
26
+
25
27
  s.add_dependency "qbxml", [">= 0.3.0"]
26
- s.add_dependency "wash_out", [">= 0.7.1"]
28
+ s.add_dependency "wash_out", ['>=0.12.0']
29
+ s.add_dependency 'actionpack', ['>= 5.0.1']
27
30
 
28
- s.add_development_dependency('guard')
29
- s.add_development_dependency('guard-rspec')
30
- s.add_development_dependency('rb-fsevent')
31
31
  s.add_development_dependency('webmock')
32
32
  s.add_development_dependency('rspec')
33
33
  s.add_development_dependency('activerecord')
34
- s.add_development_dependency('actionpack')
35
- s.add_development_dependency('rails', [">= 4.1.0"])
34
+ s.add_development_dependency('rails', [">= 5.0.1"])
36
35
  s.add_development_dependency('sqlite3')
37
36
  s.add_development_dependency('minitest')
38
37
  s.add_development_dependency('rake')
38
+ s.add_development_dependency('appraisal')
39
+ s.add_development_dependency('savon')
40
+ s.add_development_dependency('httpi')
39
41
  end
@@ -31,13 +31,18 @@ class QBWCControllerTest < ActionController::TestCase
31
31
  #_inspect_routes
32
32
  process(:qwc)
33
33
 
34
- assert_match /QBWCXML/, @response.body
35
- assert_match Regexp.new("AppName.*QbwcTestApplication #{Rails.env}.*AppName"), @response.body
36
- assert_match /AppURL.*http:\/\/test.host\/qbwc\/action.*AppURL/, @response.body
37
- assert_match /AppDescription.*Quickbooks integration.*AppDescription/, @response.body
38
- assert_match /AppSupport.*https:\/\/test.host\/.*AppSupport/, @response.body
39
- assert_match /UserName.*#{QBWC_USERNAME}.*UserName/, @response.body
40
- assert_match /FileID.*{90A44FB5-33D9-4815-AC85-BC87A7E7D1EB}.*FileID/, @response.body
34
+ assert_match(/QBWCXML/, @response.body)
35
+ assert_match(Regexp.new("AppName.*QbwcTestApplication #{Rails.env}.*AppName"), @response.body)
36
+ assert_match(/AppURL.*http:\/\/test.host\/qbwc\/action.*AppURL/, @response.body)
37
+ assert_match(/AppDescription.*Quickbooks integration.*AppDescription/, @response.body)
38
+ assert_match(/AppSupport.*https:\/\/test.host\/.*AppSupport/, @response.body)
39
+ assert_match(/UserName.*#{QBWC_USERNAME}.*UserName/, @response.body)
40
+ assert_match(/FileID.*{90A44FB5-33D9-4815-AC85-BC87A7E7D1EB}.*FileID/, @response.body)
41
+ end
42
+
43
+ test "server_version" do
44
+ _simulate_soap_request('server_version', SERVER_VERSION_SOAP_ACTION, SERVER_VERSION_PARAMS)
45
+ assert_match(/tns:serverVersionResult/, @response.body)
41
46
  end
42
47
 
43
48
  test "authenticate with no jobs" do
@@ -101,7 +106,7 @@ class QBWCControllerTest < ActionController::TestCase
101
106
  _authenticate_with_queued_job
102
107
  _simulate_soap_request('receive_response', RECEIVE_RESPONSE_SOAP_ACTION, RECEIVE_RESPONSE_PARAMS)
103
108
 
104
- assert_match /tns:receiveResponseXMLResult.*100..tns:receiveResponseXMLResult/, @response.body
109
+ assert_match(/tns:receiveResponseXMLResult.*100..tns:receiveResponseXMLResult/, @response.body)
105
110
  end
106
111
 
107
112
  class CheckErrorValuesWorker < QBWC::Worker
@@ -137,7 +142,7 @@ class QBWCControllerTest < ActionController::TestCase
137
142
  _simulate_soap_request('receive_response', RECEIVE_RESPONSE_SOAP_ACTION, RECEIVE_RESPONSE_ERROR_PARAMS)
138
143
 
139
144
  assert $HANDLE_RESPONSE_EXECUTED # https://github.com/skryl/qbwc/pull/50#discussion_r23764154
140
- assert_match /tns:receiveResponseXMLResult.*#{receive_response_xml_result}..tns:receiveResponseXMLResult/, @response.body
145
+ assert_match(/tns:receiveResponseXMLResult.*#{receive_response_xml_result}..tns:receiveResponseXMLResult/, @response.body)
141
146
  end
142
147
 
143
148
  test "receive_response error stop" do
@@ -50,7 +50,7 @@ class JobManagementTest < ActionDispatch::IntegrationTest
50
50
 
51
51
  test "requests with default session" do
52
52
  job = QBWC.add_job(:integration_test, true, '', QBWC::Worker)
53
- session = QBWC::Session.new('foo', '')
53
+ QBWC::Session.new('foo', '')
54
54
  assert_nil job.requests
55
55
  end
56
56
 
@@ -62,7 +62,7 @@ class JobManagementTest < ActionDispatch::IntegrationTest
62
62
 
63
63
  test "next_request with default session" do
64
64
  job = QBWC.add_job(:integration_test, true, '', QBWC::Worker)
65
- session = QBWC::Session.new('foo', '')
65
+ QBWC::Session.new('foo', '')
66
66
  assert_nil job.next_request
67
67
  end
68
68
 
@@ -30,7 +30,7 @@ class RequestGenerationTest < ActionDispatch::IntegrationTest
30
30
 
31
31
  class SingleRequestWorker < QBWC::Worker
32
32
  def requests(job, session, data)
33
- $SINGLE_REQUESTS_INVOKED_COUNT += 1 if $SINGLE_REQUESTS_INVOKED_COUNT.is_a?(Integer)
33
+ $SINGLE_REQUESTS_INVOKED_COUNT += 1 if defined?($SINGLE_REQUESTS_INVOKED_COUNT) && $SINGLE_REQUESTS_INVOKED_COUNT.is_a?(Integer)
34
34
  {:customer_query_rq => {:full_name => 'Quincy Bob William Carlos'}}
35
35
  end
36
36
  end
@@ -41,14 +41,14 @@ class RequestGenerationTest < ActionDispatch::IntegrationTest
41
41
  session = QBWC::Session.new('foo', '')
42
42
  nr = session.next_request
43
43
  assert_not_nil nr
44
- assert_match /FullName.*Quincy Bob William Carlos.*FullName/, nr.request
44
+ assert_match(/FullName.*Quincy Bob William Carlos.*FullName/, nr.request)
45
45
  simulate_response(session)
46
46
  assert_nil session.next_request
47
47
  end
48
48
 
49
49
  class SingleStringRequestWorker < QBWC::Worker
50
50
  def requests(job, session, data)
51
- $SINGLE_REQUESTS_INVOKED_COUNT += 1 if $SINGLE_REQUESTS_INVOKED_COUNT.is_a?(Integer)
51
+ $SINGLE_REQUESTS_INVOKED_COUNT += 1 if defined?($SINGLE_REQUESTS_INVOKED_COUNT) && $SINGLE_REQUESTS_INVOKED_COUNT.is_a?(Integer)
52
52
  QBWC_CUSTOMER_QUERY_RQ
53
53
  end
54
54
  end
@@ -59,7 +59,7 @@ class RequestGenerationTest < ActionDispatch::IntegrationTest
59
59
  session = QBWC::Session.new('foo', '')
60
60
  nr = session.next_request
61
61
  assert_not_nil nr
62
- assert_match /FullName.*#{QBWC_USERNAME}.*FullName/, nr.request
62
+ assert_match(/FullName.*#{QBWC_USERNAME}.*FullName/, nr.request)
63
63
  simulate_response(session)
64
64
  assert_nil session.next_request
65
65
  end
@@ -130,17 +130,17 @@ class RequestGenerationTest < ActionDispatch::IntegrationTest
130
130
 
131
131
  req1 = session.next_request
132
132
  assert_not_nil req1
133
- assert_match /xml.*FullName.*Quincy Bob William Carlos.*FullName/m, req1.request
133
+ assert_match(/xml.*FullName.*Quincy Bob William Carlos.*FullName/m, req1.request)
134
134
  simulate_response(session)
135
135
 
136
136
  req2 = session.next_request
137
137
  assert_not_nil req2
138
- assert_match /xml.*FullName.*Quentin Billy Wyatt Charles.*FullName/m, req2.request
138
+ assert_match(/xml.*FullName.*Quentin Billy Wyatt Charles.*FullName/m, req2.request)
139
139
  simulate_response(session)
140
140
 
141
141
  req3 = session.next_request
142
142
  assert_not_nil req3
143
- assert_match /xml.*FullName.*Quigley Brian Wally Colin.*FullName/m, req3.request
143
+ assert_match(/xml.*FullName.*Quigley Brian Wally Colin.*FullName/m, req3.request)
144
144
  simulate_response(session)
145
145
 
146
146
  assert_nil session.next_request
@@ -261,11 +261,11 @@ class RequestGenerationTest < ActionDispatch::IntegrationTest
261
261
  session = QBWC::Session.new('foo', '')
262
262
  request = session.next_request
263
263
  assert_not_nil request
264
- assert_match /CustomerAddRq.*\/CustomerAddRq/m, request.request
264
+ assert_match(/CustomerAddRq.*\/CustomerAddRq/m, request.request)
265
265
  simulate_response(session)
266
266
  assert_nil session.next_request
267
267
 
268
- assert_match /CustomerAddRq.*\/CustomerAddRq/m, extract_request(QBWC::ActiveRecord::Job::QbwcJob.first, session)[0]
268
+ assert_match(/CustomerAddRq.*\/CustomerAddRq/m, extract_request(QBWC::ActiveRecord::Job::QbwcJob.first, session)[0])
269
269
  QBWC.jobs.each {|job| assert job.requests_provided_when_job_added == true}
270
270
  end
271
271
 
@@ -296,7 +296,7 @@ class RequestGenerationTest < ActionDispatch::IntegrationTest
296
296
  session = QBWC::Session.new('foo', '')
297
297
  request = session.next_request
298
298
  assert_not_nil request
299
- assert_match /FullName.#{QBWC_USERNAME}.\/FullName/, request.request
299
+ assert_match(/FullName.#{QBWC_USERNAME}.\/FullName/, request.request)
300
300
 
301
301
  expected = {[nil, ""] => [{:customer_query_rq => {:full_name => QBWC_USERNAME}}]}
302
302
  assert_equal expected, QBWC::ActiveRecord::Job::QbwcJob.first[:requests]
@@ -327,11 +327,11 @@ class RequestGenerationTest < ActionDispatch::IntegrationTest
327
327
 
328
328
  session = QBWC::Session.new('foo', '')
329
329
  request1 = session.next_request
330
- assert_match /FullName.#{QBWC_USERNAME}.\/FullName/, request1.request
330
+ assert_match(/FullName.#{QBWC_USERNAME}.\/FullName/, request1.request)
331
331
  simulate_response(session)
332
332
 
333
333
  request2 = session.next_request
334
- assert_match /FullName.usr2 name.\/FullName/, request2.request
334
+ assert_match(/FullName.usr2 name.\/FullName/, request2.request)
335
335
  simulate_response(session)
336
336
 
337
337
  assert_nil session.next_request
@@ -30,6 +30,8 @@ class ResponseTest < ActionDispatch::IntegrationTest
30
30
 
31
31
  # Simulate controller authenticate
32
32
  ticket_string = QBWC::ActiveRecord::Session.new(QBWC_USERNAME, COMPANY).ticket
33
+ assert_not_nil(ticket_string)
34
+
33
35
  session = QBWC::Session.new(nil, COMPANY)
34
36
 
35
37
  responses.each do |resp|
@@ -21,12 +21,12 @@ class RoutesTest < ActionDispatch::IntegrationTest
21
21
  #_inspect_routes
22
22
  get '/qbwc/qwc'
23
23
 
24
- assert_match /QBWCXML/, @response.body
25
- assert_match Regexp.new("AppName.*QbwcTestApplication #{Rails.env}.*AppName"), @response.body
26
- assert_match /AppURL.*http:\/\/www.example.com\/qbwc\/action.*AppURL/, @response.body
27
- assert_match /AppDescription.*Quickbooks integration.*AppDescription/, @response.body
28
- assert_match /AppSupport.*https:\/\/www.example.com\/.*AppSupport/, @response.body
29
- assert_match /UserName.*#{QBWC_USERNAME}.*UserName/, @response.body
24
+ assert_match(/QBWCXML/, @response.body)
25
+ assert_match(Regexp.new("AppName.*QbwcTestApplication #{Rails.env}.*AppName"), @response.body)
26
+ assert_match(/AppURL.*http:\/\/www.example.com\/qbwc\/action.*AppURL/, @response.body)
27
+ assert_match(/AppDescription.*Quickbooks integration.*AppDescription/, @response.body)
28
+ assert_match(/AppSupport.*https:\/\/www.example.com\/.*AppSupport/, @response.body)
29
+ assert_match(/UserName.*#{QBWC_USERNAME}.*UserName/, @response.body)
30
30
  end
31
31
 
32
32
  test "qbwc/action without soap returns successfully" do
@@ -0,0 +1,48 @@
1
+ $:<< File.expand_path(File.dirname(__FILE__) + '/../..')
2
+ require 'test_helper.rb'
3
+ require 'savon'
4
+
5
+ class SavonClientTest < ActionDispatch::IntegrationTest
6
+
7
+ def setup
8
+ SavonClientTest.app = Rails.application
9
+
10
+ # Initialize sets view paths
11
+ SavonClientTest.app.initialize! unless SavonClientTest.app.initialized?
12
+
13
+ # Assign routes
14
+ QbwcTestApplication::Application.routes.draw do
15
+ _assign_routes
16
+ end
17
+
18
+ QBWC.clear_jobs
19
+ end
20
+
21
+ # http://blog.johnsonch.com/2013/04/18/rails-3-soap-and-testing-oh-my/
22
+ test "qbwc/action serverVersion" do
23
+ host = 'application'
24
+ url_base = "http://#{host}"
25
+ url_path = '/qbwc/action'
26
+
27
+ # http://httpirb.com/
28
+ # https://github.com/savonrb/httpi
29
+ HTTPI.adapter = :rack
30
+ HTTPI::Adapter::Rack.mount(host, SavonClientTest.app)
31
+
32
+ # https://github.com/savonrb/savon#usage-example
33
+ # https://github.com/inossidabile/wash_out#usage
34
+ client = Savon::Client.new({:wsdl => url_base + url_path })
35
+ result = client.call(:server_version, :message => nil)
36
+
37
+ # Use this assertion when QBWC::Controller.server_version_response returns nil
38
+ if WashOut::VERSION == "0.10.0"
39
+ assert_equal({:"@xsi:type"=>"xsd:string"}, result.body[:server_version_response][:server_version_result])
40
+ else
41
+ assert_nil result.body[:server_version_response][:server_version_result]
42
+ end
43
+
44
+ # Use this assertion when QBWC::Controller.server_version_response returns a value
45
+ # assert_equal("SERVER_VERSION_RESPONSE", result.body[:server_version_response][:server_version_result])
46
+ end
47
+
48
+ end
@@ -89,7 +89,7 @@ class SessionTest < ActionDispatch::IntegrationTest
89
89
  assert_equal 1, QBWC.pending_jobs(COMPANY, session).count
90
90
 
91
91
  # Simulate controller send_request
92
- request = session.request_to_send
92
+ session.request_to_send
93
93
  end
94
94
 
95
95
  class ConditionalTestWorker < QBWC::Worker
@@ -9,6 +9,19 @@ require 'active_record'
9
9
  require 'action_controller'
10
10
  require 'rails'
11
11
 
12
+ # Determine location of local wash_out gem
13
+ # https://github.com/rubygems/rubygems/blob/master/lib/rubygems/commands/which_command.rb
14
+ require 'rubygems/commands/which_command'
15
+ which_command = Gem::Commands::WhichCommand.new
16
+ paths = which_command.find_paths('wash_out', $LOAD_PATH)
17
+ wash_out_lib = File.dirname(paths[0]) # Alternate technique: File.dirname(`gem which wash_out`)
18
+
19
+ # Add wash_out to autoload_paths so that WashOutHelper can be included directly
20
+ # http://api.rubyonrails.org/classes/AbstractController/Helpers/ClassMethods.html#method-i-helper
21
+ # http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#require-dependency
22
+ # http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoload-paths
23
+ ActiveSupport::Dependencies.autoload_paths << "#{wash_out_lib}/../app/helpers"
24
+
12
25
  $:<< File.expand_path(File.dirname(__FILE__) + '/../lib')
13
26
  require 'qbwc'
14
27
  require 'qbwc/controller'
@@ -89,6 +102,8 @@ QbwcTestApplication::Application.routes.draw do
89
102
  end
90
103
 
91
104
  class QbwcController < ActionController::Base
105
+ protect_from_forgery with: :exception # Must precede QWBC::Controller to emulate Rails load order
106
+
92
107
  include Rails.application.routes.url_helpers
93
108
  include QBWC::Controller
94
109
  end
@@ -176,6 +191,12 @@ AUTHENTICATE_WASH_OUT_SOAP_DATA = {
176
191
  }
177
192
  }
178
193
 
194
+ SERVER_VERSION_PARAMS = {
195
+ :@xmlns => "http://developer.intuit.com/"
196
+ }
197
+
198
+ SERVER_VERSION_SOAP_ACTION = :serverVersion
199
+
179
200
  SEND_REQUEST_PARAMS = {
180
201
  :qbXMLCountry => "US",
181
202
  :qbXMLMajorVers => "13",
@@ -202,18 +223,44 @@ RECEIVE_RESPONSE_ERROR_PARAMS = {
202
223
 
203
224
  RECEIVE_RESPONSE_SOAP_ACTION = :receiveResponseXML
204
225
 
226
+ #-------------------------------------------
227
+ def _controller_env_is_required?
228
+ # qbwc requires minimum wash_out 0.10.0
229
+ # wash_out 0.10.0 uses controller env
230
+ # wash_out 0.11.0 uses request.env
231
+ WashOut::VERSION == "0.10.0"
232
+ end
233
+
234
+ #-------------------------------------------
235
+ def _set_controller_env_if_required
236
+ if _controller_env_is_required?
237
+ @controller.set_request!(@request) if Rails::VERSION::MAJOR >= 5
238
+ @controller.env["wash_out.soap_data"] = @request.env["wash_out.soap_data"]
239
+ end
240
+ end
241
+
205
242
  #-------------------------------------------
206
243
  def _simulate_soap_request(http_action, soap_action, soap_params)
207
244
 
208
- ticket = QBWC::ActiveRecord::Session::QbwcSession.first.ticket
209
- wash_out_soap_data = { :Envelope => { :Body => { soap_action => soap_params.update(:ticket => ticket) }}}
245
+ session = QBWC::ActiveRecord::Session::QbwcSession.first
246
+ unless session.blank?
247
+ ticket = session.ticket
248
+ soap_params = soap_params.update(:ticket => ticket)
249
+ end
250
+
251
+ wash_out_soap_data = { :Envelope => { :Body => { soap_action => soap_params }}}
210
252
 
211
253
  # http://twobitlabs.com/2010/09/setting-request-headers-in-rails-functional-tests/
212
254
  @request.env["wash_out.soap_action"] = soap_action.to_s
213
255
  @request.env["wash_out.soap_data"] = wash_out_soap_data
214
- @controller.env["wash_out.soap_data"] = @request.env["wash_out.soap_data"]
256
+ _set_controller_env_if_required
257
+
258
+ if Rails::VERSION::MAJOR <= 4
259
+ post http_action, use_route: :qbwc_action
260
+ else
261
+ post http_action, params: { use_route: :qbwc_action }
262
+ end
215
263
 
216
- post http_action, use_route: :qbwc_action
217
264
  end
218
265
 
219
266
  #-------------------------------------------
@@ -221,7 +268,7 @@ def _authenticate
221
268
  # http://twobitlabs.com/2010/09/setting-request-headers-in-rails-functional-tests/
222
269
  @request.env["wash_out.soap_action"] = AUTHENTICATE_SOAP_ACTION.to_s
223
270
  @request.env["wash_out.soap_data"] = AUTHENTICATE_WASH_OUT_SOAP_DATA
224
- @controller.env["wash_out.soap_data"] = @request.env["wash_out.soap_data"]
271
+ _set_controller_env_if_required
225
272
 
226
273
  process(:authenticate)
227
274
  end
@@ -241,7 +288,7 @@ def _authenticate_wrong_password
241
288
  bad_password_soap_data[:Envelope][:Body][AUTHENTICATE_SOAP_ACTION][:strPassword] = 'something wrong'
242
289
  @request.env["wash_out.soap_action"] = AUTHENTICATE_SOAP_ACTION.to_s
243
290
  @request.env["wash_out.soap_data"] = bad_password_soap_data
244
- @controller.env["wash_out.soap_data"] = @request.env["wash_out.soap_data"]
291
+ _set_controller_env_if_required
245
292
 
246
293
  process(:authenticate)
247
294
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qbwc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Skryl
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-03-03 00:00:00.000000000 Z
14
+ date: 2017-12-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: qbxml
@@ -33,30 +33,30 @@ dependencies:
33
33
  requirements:
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.7.1
36
+ version: 0.12.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.7.1
43
+ version: 0.12.0
44
44
  - !ruby/object:Gem::Dependency
45
- name: guard
45
+ name: actionpack
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: '0'
51
- type: :development
50
+ version: 5.0.1
51
+ type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
- version: '0'
57
+ version: 5.0.1
58
58
  - !ruby/object:Gem::Dependency
59
- name: guard-rspec
59
+ name: webmock
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - ">="
@@ -70,7 +70,7 @@ dependencies:
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
- name: rb-fsevent
73
+ name: rspec
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - ">="
@@ -84,7 +84,7 @@ dependencies:
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  - !ruby/object:Gem::Dependency
87
- name: webmock
87
+ name: activerecord
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - ">="
@@ -98,21 +98,21 @@ dependencies:
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  - !ruby/object:Gem::Dependency
101
- name: rspec
101
+ name: rails
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - ">="
105
105
  - !ruby/object:Gem::Version
106
- version: '0'
106
+ version: 5.0.1
107
107
  type: :development
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - ">="
112
112
  - !ruby/object:Gem::Version
113
- version: '0'
113
+ version: 5.0.1
114
114
  - !ruby/object:Gem::Dependency
115
- name: activerecord
115
+ name: sqlite3
116
116
  requirement: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="
@@ -126,7 +126,7 @@ dependencies:
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  - !ruby/object:Gem::Dependency
129
- name: actionpack
129
+ name: minitest
130
130
  requirement: !ruby/object:Gem::Requirement
131
131
  requirements:
132
132
  - - ">="
@@ -140,21 +140,21 @@ dependencies:
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  - !ruby/object:Gem::Dependency
143
- name: rails
143
+ name: rake
144
144
  requirement: !ruby/object:Gem::Requirement
145
145
  requirements:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
- version: 4.1.0
148
+ version: '0'
149
149
  type: :development
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
- version: 4.1.0
155
+ version: '0'
156
156
  - !ruby/object:Gem::Dependency
157
- name: sqlite3
157
+ name: appraisal
158
158
  requirement: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - ">="
@@ -168,7 +168,7 @@ dependencies:
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0'
170
170
  - !ruby/object:Gem::Dependency
171
- name: minitest
171
+ name: savon
172
172
  requirement: !ruby/object:Gem::Requirement
173
173
  requirements:
174
174
  - - ">="
@@ -182,7 +182,7 @@ dependencies:
182
182
  - !ruby/object:Gem::Version
183
183
  version: '0'
184
184
  - !ruby/object:Gem::Dependency
185
- name: rake
185
+ name: httpi
186
186
  requirement: !ruby/object:Gem::Requirement
187
187
  requirements:
188
188
  - - ">="
@@ -209,12 +209,14 @@ files:
209
209
  - ".gitignore"
210
210
  - ".rspec"
211
211
  - ".travis.yml"
212
+ - Appraisals
212
213
  - CHANGELOG.md
213
214
  - Gemfile
214
- - Guardfile
215
215
  - LICENSE.txt
216
216
  - README.md
217
217
  - Rakefile
218
+ - gemfiles/rails_5.0.gemfile
219
+ - gemfiles/rails_5.1.gemfile
218
220
  - lib/generators/qbwc/install/install_generator.rb
219
221
  - lib/generators/qbwc/install/templates/config/qbwc.rb
220
222
  - lib/generators/qbwc/install/templates/controllers/qbwc_controller.rb
@@ -241,9 +243,9 @@ files:
241
243
  - test/qbwc/integration/request_generation_test.rb
242
244
  - test/qbwc/integration/response_test.rb
243
245
  - test/qbwc/integration/routes_test.rb
246
+ - test/qbwc/integration/savon_client_test.rb
244
247
  - test/qbwc/integration/session_test.rb
245
248
  - test/test_helper.rb
246
- - test/wash_out_helper.rb
247
249
  homepage: ''
248
250
  licenses: []
249
251
  metadata: {}
@@ -255,7 +257,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
257
  requirements:
256
258
  - - ">="
257
259
  - !ruby/object:Gem::Version
258
- version: '0'
260
+ version: 2.2.2
259
261
  required_rubygems_version: !ruby/object:Gem::Requirement
260
262
  requirements:
261
263
  - - ">="
@@ -263,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
265
  version: '0'
264
266
  requirements: []
265
267
  rubyforge_project: qbwc
266
- rubygems_version: 2.4.6
268
+ rubygems_version: 2.6.8
267
269
  signing_key:
268
270
  specification_version: 4
269
271
  summary: A Rails interface for Intuit's Quickbooks Web Connector
data/Guardfile DELETED
@@ -1,46 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard 'rspec' do
5
- watch(%r{^spec/.+_spec\.rb$})
6
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
- watch('spec/spec_helper.rb') { "spec" }
8
-
9
- # Rails example
10
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
- watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
- watch('config/routes.rb') { "spec/routing" }
15
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
-
17
- # Capybara features specs
18
- watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
-
20
- # Turnip features and steps
21
- watch(%r{^spec/acceptance/(.+)\.feature$})
22
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
- end
24
-
25
-
26
- guard 'rspec' do
27
- watch(%r{^spec/.+_spec\.rb$})
28
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
29
- watch('spec/spec_helper.rb') { "spec" }
30
-
31
- # Rails example
32
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
33
- watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
34
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
35
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
36
- watch('config/routes.rb') { "spec/routing" }
37
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
38
-
39
- # Capybara features specs
40
- watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
41
-
42
- # Turnip features and steps
43
- watch(%r{^spec/acceptance/(.+)\.feature$})
44
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
45
- end
46
-
@@ -1,76 +0,0 @@
1
- # Copy of what's in the gem. Can't figure out how to include it.
2
- module WashOutHelper
3
-
4
- def wsdl_data_options(param)
5
- case controller.soap_config.wsdl_style
6
- when 'rpc'
7
- { :"xsi:type" => param.namespaced_type }
8
- when 'document'
9
- { }
10
- end
11
- end
12
-
13
- def wsdl_data(xml, params)
14
- params.each do |param|
15
- tag_name = param.name
16
- param_options = wsdl_data_options(param)
17
-
18
- if !param.struct?
19
- if !param.multiplied
20
- xml.tag! tag_name, param.value, param_options
21
- else
22
- param.value = [] unless param.value.is_a?(Array)
23
- param.value.each do |v|
24
- xml.tag! tag_name, v, param_options
25
- end
26
- end
27
- else
28
- if !param.multiplied
29
- xml.tag! tag_name, param_options do
30
- wsdl_data(xml, param.map)
31
- end
32
- else
33
- param.map.each do |p|
34
- xml.tag! tag_name, param_options do
35
- wsdl_data(xml, p.map)
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
42
-
43
- def wsdl_type(xml, param, defined=[])
44
- more = []
45
-
46
- if param.struct?
47
- if !defined.include?(param.basic_type)
48
- xml.tag! "xsd:complexType", :name => param.basic_type do
49
- xml.tag! "xsd:sequence" do
50
- param.map.each do |value|
51
- more << value if value.struct?
52
- xml.tag! "xsd:element", wsdl_occurence(value, false, :name => value.name, :type => value.namespaced_type)
53
- end
54
- end
55
- end
56
-
57
- defined << param.basic_type
58
- elsif !param.classified?
59
- raise RuntimeError, "Duplicate use of `#{param.basic_type}` type name. Consider using classified types."
60
- end
61
- end
62
-
63
- more.each do |p|
64
- wsdl_type xml, p, defined
65
- end
66
- end
67
-
68
- def wsdl_occurence(param, inject, extend_with = {})
69
- data = !param.multiplied ? {} : {
70
- "#{'xsi:' if inject}minOccurs" => 0,
71
- "#{'xsi:' if inject}maxOccurs" => 'unbounded'
72
- }
73
-
74
- extend_with.merge(data)
75
- end
76
- end