quickbooks_web_connector 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +109 -0
  3. data/Rakefile +28 -0
  4. data/app/assets/javascripts/quickbooks_web_connector/application.js +15 -0
  5. data/app/assets/stylesheets/quickbooks_web_connector/application.css +13 -0
  6. data/app/controllers/quickbooks_web_connector/application_controller.rb +5 -0
  7. data/app/controllers/quickbooks_web_connector/qwc_controller.rb +12 -0
  8. data/app/controllers/quickbooks_web_connector/soap_controller.rb +10 -0
  9. data/app/helpers/quickbooks_web_connector/application_helper.rb +4 -0
  10. data/app/views/layouts/quickbooks_web_connector/application.html.erb +14 -0
  11. data/app/views/quickbooks_web_connector/qwc/qwc.xml.builder +12 -0
  12. data/config/routes.rb +6 -0
  13. data/lib/quickbooks_web_connector/config.rb +35 -0
  14. data/lib/quickbooks_web_connector/engine.rb +5 -0
  15. data/lib/quickbooks_web_connector/job.rb +61 -0
  16. data/lib/quickbooks_web_connector/json_coder.rb +23 -0
  17. data/lib/quickbooks_web_connector/soap_wrapper/QBWebConnectorSvc.rb +72 -0
  18. data/lib/quickbooks_web_connector/soap_wrapper/default.rb +204 -0
  19. data/lib/quickbooks_web_connector/soap_wrapper/defaultMappingRegistry.rb +166 -0
  20. data/lib/quickbooks_web_connector/soap_wrapper/defaultServant.rb +140 -0
  21. data/lib/quickbooks_web_connector/soap_wrapper.rb +30 -0
  22. data/lib/quickbooks_web_connector/version.rb +3 -0
  23. data/lib/quickbooks_web_connector.rb +127 -0
  24. data/lib/tasks/quickbooks_web_connector_tasks.rake +4 -0
  25. data/spec/config/config_spec.rb +83 -0
  26. data/spec/controllers/quickbooks_web_connector/qwc_controller_spec.rb +29 -0
  27. data/spec/controllers/quickbooks_web_connector/soap_controller_spec.rb +306 -0
  28. data/spec/dummy/README.rdoc +261 -0
  29. data/spec/dummy/Rakefile +7 -0
  30. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  31. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  32. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  33. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  34. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/spec/dummy/config/application.rb +59 -0
  36. data/spec/dummy/config/boot.rb +10 -0
  37. data/spec/dummy/config/database.yml +25 -0
  38. data/spec/dummy/config/environment.rb +5 -0
  39. data/spec/dummy/config/environments/development.rb +37 -0
  40. data/spec/dummy/config/environments/production.rb +67 -0
  41. data/spec/dummy/config/environments/test.rb +37 -0
  42. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  43. data/spec/dummy/config/initializers/inflections.rb +15 -0
  44. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  45. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  46. data/spec/dummy/config/initializers/session_store.rb +8 -0
  47. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/spec/dummy/config/locales/en.yml +5 -0
  49. data/spec/dummy/config/routes.rb +6 -0
  50. data/spec/dummy/config.ru +4 -0
  51. data/spec/dummy/db/test.sqlite3 +0 -0
  52. data/spec/dummy/log/development.log +0 -0
  53. data/spec/dummy/log/test.log +26009 -0
  54. data/spec/dummy/public/404.html +26 -0
  55. data/spec/dummy/public/422.html +26 -0
  56. data/spec/dummy/public/500.html +25 -0
  57. data/spec/dummy/public/favicon.ico +0 -0
  58. data/spec/dummy/script/rails +6 -0
  59. data/spec/quickbooks_web_connector/soap_wrapper/defaultServant_spec.rb +150 -0
  60. data/spec/quickbooks_web_connector_spec.rb +47 -0
  61. data/spec/routing/quickbooks_web_connector_spec.rb +17 -0
  62. data/spec/spec_helper.rb +50 -0
  63. data/spec/support/redis/dump.rdb +1 -0
  64. data/spec/support/redis/redis-test.conf +115 -0
  65. data/spec/views/quickbooks_web_connector/qwc/qwc.xml.builder_spec.rb +56 -0
  66. metadata +232 -0
@@ -0,0 +1,166 @@
1
+ require 'soap/mapping'
2
+
3
+ module QuickbooksWebConnector
4
+ module SoapWrapper
5
+ module DefaultMappingRegistry
6
+ EncodedRegistry = ::SOAP::Mapping::EncodedRegistry.new
7
+ LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new
8
+ NsDeveloperIntuitCom = "http://developer.intuit.com/"
9
+
10
+ EncodedRegistry.register(
11
+ :class => ArrayOfString,
12
+ :schema_type => XSD::QName.new(NsDeveloperIntuitCom, "ArrayOfString"),
13
+ :schema_element => [
14
+ ["string", "SOAP::SOAPString[]", [0, nil]]
15
+ ]
16
+ )
17
+
18
+ LiteralRegistry.register(
19
+ :class => ArrayOfString,
20
+ :schema_type => XSD::QName.new(NsDeveloperIntuitCom, "ArrayOfString"),
21
+ :schema_element => [
22
+ ["string", "SOAP::SOAPString[]", [0, nil]]
23
+ ]
24
+ )
25
+
26
+ LiteralRegistry.register(
27
+ :class => Authenticate,
28
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "authenticate"),
29
+ :schema_element => [
30
+ ["strUserName", "SOAP::SOAPString", [0, 1]],
31
+ ["strPassword", "SOAP::SOAPString", [0, 1]]
32
+ ]
33
+ )
34
+
35
+ LiteralRegistry.register(
36
+ :class => AuthenticateResponse,
37
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "authenticateResponse"),
38
+ :schema_element => [
39
+ ["authenticateResult", "ArrayOfString", [0, 1]]
40
+ ]
41
+ )
42
+
43
+ LiteralRegistry.register(
44
+ :class => ServerVersion,
45
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "serverVersion"),
46
+ :schema_element => [
47
+ ["strVersion", "SOAP::SOAPString", [0, 1]]
48
+ ]
49
+ )
50
+
51
+ LiteralRegistry.register(
52
+ :class => ServerVersionResponse,
53
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "serverVersionResponse"),
54
+ :schema_element => [
55
+ ["serverVersionResult", "SOAP::SOAPString", [0, 1]]
56
+ ]
57
+ )
58
+
59
+ LiteralRegistry.register(
60
+ :class => ClientVersion,
61
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "clientVersion"),
62
+ :schema_element => [
63
+ ["strVersion", "SOAP::SOAPString", [0, 1]]
64
+ ]
65
+ )
66
+
67
+ LiteralRegistry.register(
68
+ :class => ClientVersionResponse,
69
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "clientVersionResponse"),
70
+ :schema_element => [
71
+ ["clientVersionResult", "SOAP::SOAPString", [0, 1]]
72
+ ]
73
+ )
74
+
75
+ LiteralRegistry.register(
76
+ :class => SendRequestXML,
77
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "sendRequestXML"),
78
+ :schema_element => [
79
+ ["ticket", "SOAP::SOAPString", [0, 1]],
80
+ ["strHCPResponse", "SOAP::SOAPString", [0, 1]],
81
+ ["strCompanyFileName", "SOAP::SOAPString", [0, 1]],
82
+ ["qbXMLCountry", "SOAP::SOAPString", [0, 1]],
83
+ ["qbXMLMajorVers", "SOAP::SOAPInt"],
84
+ ["qbXMLMinorVers", "SOAP::SOAPInt"]
85
+ ]
86
+ )
87
+
88
+ LiteralRegistry.register(
89
+ :class => SendRequestXMLResponse,
90
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "sendRequestXMLResponse"),
91
+ :schema_element => [
92
+ ["sendRequestXMLResult", "SOAP::SOAPString", [0, 1]]
93
+ ]
94
+ )
95
+
96
+ LiteralRegistry.register(
97
+ :class => ReceiveResponseXML,
98
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "receiveResponseXML"),
99
+ :schema_element => [
100
+ ["ticket", "SOAP::SOAPString", [0, 1]],
101
+ ["response", "SOAP::SOAPString", [0, 1]],
102
+ ["hresult", "SOAP::SOAPString", [0, 1]],
103
+ ["message", "SOAP::SOAPString", [0, 1]]
104
+ ]
105
+ )
106
+
107
+ LiteralRegistry.register(
108
+ :class => ReceiveResponseXMLResponse,
109
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "receiveResponseXMLResponse"),
110
+ :schema_element => [
111
+ ["receiveResponseXMLResult", "SOAP::SOAPInt"]
112
+ ]
113
+ )
114
+
115
+ LiteralRegistry.register(
116
+ :class => ConnectionError,
117
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "connectionError"),
118
+ :schema_element => [
119
+ ["ticket", "SOAP::SOAPString", [0, 1]],
120
+ ["hresult", "SOAP::SOAPString", [0, 1]],
121
+ ["message", "SOAP::SOAPString", [0, 1]]
122
+ ]
123
+ )
124
+
125
+ LiteralRegistry.register(
126
+ :class => ConnectionErrorResponse,
127
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "connectionErrorResponse"),
128
+ :schema_element => [
129
+ ["connectionErrorResult", "SOAP::SOAPString", [0, 1]]
130
+ ]
131
+ )
132
+
133
+ LiteralRegistry.register(
134
+ :class => GetLastError,
135
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "getLastError"),
136
+ :schema_element => [
137
+ ["ticket", "SOAP::SOAPString", [0, 1]]
138
+ ]
139
+ )
140
+
141
+ LiteralRegistry.register(
142
+ :class => GetLastErrorResponse,
143
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "getLastErrorResponse"),
144
+ :schema_element => [
145
+ ["getLastErrorResult", "SOAP::SOAPString", [0, 1]]
146
+ ]
147
+ )
148
+
149
+ LiteralRegistry.register(
150
+ :class => CloseConnection,
151
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "closeConnection"),
152
+ :schema_element => [
153
+ ["ticket", "SOAP::SOAPString", [0, 1]]
154
+ ]
155
+ )
156
+
157
+ LiteralRegistry.register(
158
+ :class => CloseConnectionResponse,
159
+ :schema_name => XSD::QName.new(NsDeveloperIntuitCom, "closeConnectionResponse"),
160
+ :schema_element => [
161
+ ["closeConnectionResult", "SOAP::SOAPString", [0, 1]]
162
+ ]
163
+ )
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,140 @@
1
+ module QuickbooksWebConnector
2
+ module SoapWrapper
3
+
4
+ class QBWebConnectorSvcSoap
5
+ # SYNOPSIS
6
+ # serverVersion(parameters)
7
+ #
8
+ # ARGS
9
+ # parameters ServerVersion - {http://developer.intuit.com/}serverVersion
10
+ #
11
+ # RETURNS
12
+ # parameters ServerVersionResponse - {http://developer.intuit.com/}serverVersionResponse
13
+ #
14
+ def serverVersion(parameters)
15
+ ServerVersionResponse.new(QuickbooksWebConnector.config.server_version)
16
+ end
17
+
18
+ # SYNOPSIS
19
+ # clientVersion(parameters)
20
+ #
21
+ # ARGS
22
+ # parameters ClientVersion - {http://developer.intuit.com/}clientVersion
23
+ #
24
+ # RETURNS
25
+ # parameters ClientVersionResponse - {http://developer.intuit.com/}clientVersionResponse
26
+ #
27
+ def clientVersion(parameters)
28
+ clientVersionResult = nil
29
+
30
+ if QuickbooksWebConnector.config.minimum_web_connector_client_version && QuickbooksWebConnector.config.minimum_web_connector_client_version.to_s > parameters.strVersion
31
+ clientVersionResult = "E:This version of QuickBooks Web Connector is outdated. Version #{QuickbooksWebConnector.config.minimum_web_connector_client_version} or greater is required."
32
+ end
33
+
34
+ ClientVersionResponse.new(clientVersionResult)
35
+ end
36
+
37
+ # SYNOPSIS
38
+ # authenticate(parameters)
39
+ #
40
+ # ARGS
41
+ # parameters Authenticate - {http://developer.intuit.com/}authenticate
42
+ #
43
+ # RETURNS
44
+ # parameters AuthenticateResponse - {http://developer.intuit.com/}authenticateResponse
45
+ #
46
+ def authenticate(parameters)
47
+ token = SecureRandom.uuid
48
+ result = if parameters.strUserName == QuickbooksWebConnector.config.username && parameters.strPassword == QuickbooksWebConnector.config.password
49
+ if QuickbooksWebConnector.size > 0
50
+ QuickbooksWebConnector.config.company_file_path
51
+ else
52
+ 'none'
53
+ end
54
+ else
55
+ 'nvu'
56
+ end
57
+
58
+ AuthenticateResponse.new([token, result, nil, nil])
59
+ end
60
+
61
+ # SYNOPSIS
62
+ # sendRequestXML(parameters)
63
+ #
64
+ # ARGS
65
+ # parameters SendRequestXML - {http://developer.intuit.com/}sendRequestXML
66
+ #
67
+ # RETURNS
68
+ # parameters SendRequestXMLResponse - {http://developer.intuit.com/}sendRequestXMLResponse
69
+ #
70
+ def sendRequestXML(parameters)
71
+ job = QuickbooksWebConnector::Job.peek
72
+ request_xml = job ? job.request_xml : nil
73
+
74
+ SendRequestXMLResponse.new request_xml
75
+ end
76
+
77
+ # SYNOPSIS
78
+ # receiveResponseXML(parameters)
79
+ #
80
+ # ARGS
81
+ # parameters ReceiveResponseXML - {http://developer.intuit.com/}receiveResponseXML
82
+ #
83
+ # RETURNS
84
+ # parameters ReceiveResponseXMLResponse - {http://developer.intuit.com/}receiveResponseXMLResponse
85
+ #
86
+ def receiveResponseXML(parameters)
87
+ job = QuickbooksWebConnector::Job.reserve
88
+ job.response_xml = parameters.response
89
+ job.perform
90
+
91
+ # TODO: This just returns 1% by default. Need a way to determine the actual percentage done.
92
+ progress = QuickbooksWebConnector.size == 0 ? 100 : 1
93
+
94
+ ReceiveResponseXMLResponse.new(progress)
95
+ end
96
+
97
+ # SYNOPSIS
98
+ # connectionError(parameters)
99
+ #
100
+ # ARGS
101
+ # parameters ConnectionError - {http://developer.intuit.com/}connectionError
102
+ #
103
+ # RETURNS
104
+ # parameters ConnectionErrorResponse - {http://developer.intuit.com/}connectionErrorResponse
105
+ #
106
+ def connectionError(parameters)
107
+ p [parameters]
108
+ raise NotImplementedError.new
109
+ end
110
+
111
+ # SYNOPSIS
112
+ # getLastError(parameters)
113
+ #
114
+ # ARGS
115
+ # parameters GetLastError - {http://developer.intuit.com/}getLastError
116
+ #
117
+ # RETURNS
118
+ # parameters GetLastErrorResponse - {http://developer.intuit.com/}getLastErrorResponse
119
+ #
120
+ def getLastError(parameters)
121
+ p [parameters]
122
+ raise NotImplementedError.new
123
+ end
124
+
125
+ # SYNOPSIS
126
+ # closeConnection(parameters)
127
+ #
128
+ # ARGS
129
+ # parameters CloseConnection - {http://developer.intuit.com/}closeConnection
130
+ #
131
+ # RETURNS
132
+ # parameters CloseConnectionResponse - {http://developer.intuit.com/}closeConnectionResponse
133
+ #
134
+ def closeConnection(parameters)
135
+ CloseConnectionResponse.new
136
+ end
137
+ end
138
+
139
+ end
140
+ end
@@ -0,0 +1,30 @@
1
+ module QuickbooksWebConnector
2
+ module SoapWrapper
3
+
4
+ def self.route(request)
5
+ @router = ::SOAP::RPC::Router.new('QBWebConnectorSvcSoap')
6
+ @router.mapping_registry = DefaultMappingRegistry::EncodedRegistry
7
+ @router.literal_mapping_registry = DefaultMappingRegistry::LiteralRegistry
8
+
9
+ servant = QBWebConnectorSvcSoap.new
10
+ QBWebConnectorSvcSoap::Methods.each do |definitions|
11
+ opt = definitions.last
12
+ if opt[:request_style] == :document
13
+ @router.add_document_operation(servant, *definitions)
14
+ else
15
+ @router.add_rpc_operation(servant, *definitions)
16
+ end
17
+ end
18
+
19
+ @connection_data = ::SOAP::StreamHandler::ConnectionData.new
20
+ @connection_data.receive_string = request.raw_post
21
+ @connection_data.receive_contenttype = request.content_type
22
+ @connection_data.soapaction = nil
23
+
24
+ @router.external_ces = nil
25
+ response_data = @router.route(@connection_data)
26
+ response_data.send_string
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module QuickbooksWebConnector
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,127 @@
1
+ require 'redis/namespace'
2
+ require 'securerandom'
3
+ require 'soap/rpc/standaloneServer'
4
+
5
+ require 'quickbooks_web_connector/config'
6
+ require 'quickbooks_web_connector/job'
7
+ require 'quickbooks_web_connector/json_coder'
8
+
9
+ require 'quickbooks_web_connector/soap_wrapper/default'
10
+ require 'quickbooks_web_connector/soap_wrapper/defaultMappingRegistry'
11
+ require 'quickbooks_web_connector/soap_wrapper/defaultServant'
12
+ require 'quickbooks_web_connector/soap_wrapper/QBWebConnectorSvc'
13
+ require "quickbooks_web_connector/soap_wrapper"
14
+
15
+ require "quickbooks_web_connector/engine"
16
+
17
+ module QuickbooksWebConnector
18
+ extend self
19
+
20
+ # Accepts:
21
+ # 1. A 'hostname:port' String
22
+ # 2. A 'hostname:port:db' String (to select the Redis db)
23
+ # 3. A 'hostname:port/namespace' String (to set the Redis namespace)
24
+ # 4. A Redis URL String 'redis://host:port'
25
+ # 5. An instance of `Redis`, `Redis::Client`, `Redis::DistRedis`,
26
+ # or `Redis::Namespace`.
27
+ def redis=(server)
28
+ case server
29
+ when String
30
+ if server['redis://']
31
+ redis = Redis.connect(:url => server, :thread_safe => true)
32
+ else
33
+ server, namespace = server.split('/', 2)
34
+ host, port, db = server.split(':')
35
+ redis = Redis.new(:host => host, :port => port,
36
+ :thread_safe => true, :db => db)
37
+ end
38
+ namespace ||= :qwc
39
+
40
+ @redis = Redis::Namespace.new(namespace, :redis => redis)
41
+ when Redis::Namespace
42
+ @redis = server
43
+ else
44
+ @redis = Redis::Namespace.new(:qwc, :redis => server)
45
+ end
46
+ end
47
+
48
+ # Returns the current Redis connection. If none has been created, will
49
+ # create a new one.
50
+ def redis
51
+ return @redis if @redis
52
+ self.redis = Redis.respond_to?(:connect) ? Redis.connect(:thread_safe => true) : "localhost:6379"
53
+ self.redis
54
+ end
55
+
56
+ # Encapsulation of encode/decode. Overwrite this to use it across QuickbooksWebConnector.
57
+ # This defaults to JSON for backwards compatibilty.
58
+ def coder
59
+ @coder ||= JsonCoder.new
60
+ end
61
+ attr_writer :coder
62
+
63
+ #
64
+ # job shortcuts
65
+ #
66
+
67
+ # This method can be used to conveniently add a job to the queue.
68
+ # It assumes the class you're passing it is a real Ruby class (not
69
+ # a string or reference).
70
+ def enqueue(xml, klass, *args)
71
+ Job.create(xml, klass, *args)
72
+ end
73
+
74
+ # This method will return a `QuickbooksWebConnector::Job` object or
75
+ # a non-true value depending on whether a job can be obtained.
76
+ def reserve
77
+ Job.reserve
78
+ end
79
+
80
+ #
81
+ # queue manipulation
82
+ #
83
+
84
+ # Pushes a job onto the queue. The item should be any JSON-able Ruby object.
85
+
86
+ # The `item` is expected to be a hash with the following keys:
87
+ #
88
+ # xml - The XML to send to Quickbooks as a String.
89
+ # class - The String name of the response handler.
90
+ # args - An Array of arguments to pass the handler. Usually passed
91
+ # via `class.to_class.perform(*args)`.
92
+ #
93
+ # Example
94
+ #
95
+ # QuickbooksWebConnector.push('xml' => '<some><xml></xml></some>', class' => 'CustomerAddResponseHandler', 'args' => [ 35 ])
96
+ #
97
+ # Returns nothing
98
+ def push(item)
99
+ redis.rpush :queue, encode(item)
100
+ end
101
+
102
+ # Pops a job off the queue.
103
+ #
104
+ # Returns a Ruby object.
105
+ def pop
106
+ decode @redis.lpop(:queue)
107
+ end
108
+
109
+ # Returns an integer representing the size of the queue.
110
+ def size
111
+ redis.llen :queue
112
+ end
113
+
114
+ # Returns the next item currently queued, without removing it.
115
+ def peek
116
+ decode redis.lindex :queue, 0
117
+ end
118
+
119
+ def encode(object)
120
+ coder.encode object
121
+ end
122
+
123
+ def decode(object)
124
+ coder.decode object
125
+ end
126
+
127
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :quickbooks_web_connector do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+
3
+ describe QuickbooksWebConnector::Configuration do
4
+ subject { QuickbooksWebConnector.config }
5
+
6
+ describe 'server_version' do
7
+
8
+ context 'by default' do
9
+ its(:server_version) { should eq '1.0.0' }
10
+ end
11
+
12
+ context 'configured via config block' do
13
+ before { QuickbooksWebConnector.configure { |c| c.server_version = '1.2.3' } }
14
+
15
+ its(:server_version) { should eq '1.2.3' }
16
+
17
+ after { QuickbooksWebConnector.configure { |c| c.server_version = '1.0.0' } }
18
+ end
19
+
20
+ end
21
+
22
+ describe 'minimum_web_connector_client_version' do
23
+
24
+ context 'by default' do
25
+ its(:minimum_web_connector_client_version) { should be_nil }
26
+ end
27
+
28
+ context 'configured via config block' do
29
+ before { QuickbooksWebConnector.configure { |c| c.minimum_web_connector_client_version = '2.1.0.30' } }
30
+
31
+ its(:minimum_web_connector_client_version) { should eq '2.1.0.30' }
32
+
33
+ after { QuickbooksWebConnector.configure { |c| c.minimum_web_connector_client_version = nil } }
34
+ end
35
+
36
+ end
37
+
38
+ context 'username' do
39
+
40
+ context 'by default' do
41
+ its(:username) { should eq 'web_connector' }
42
+ end
43
+
44
+ context 'configured via a config block' do
45
+ before { QuickbooksWebConnector.configure { |c| c.username = 'jsmith' } }
46
+
47
+ its(:username) { should eq 'jsmith' }
48
+
49
+ after { QuickbooksWebConnector.configure { |c| c.username = 'web_connector' } }
50
+ end
51
+ end
52
+
53
+ context 'password' do
54
+
55
+ context 'by default' do
56
+ its(:password) { should eq 'secret' }
57
+ end
58
+
59
+ context 'configured via a config block' do
60
+ before { QuickbooksWebConnector.configure { |c| c.password = 'quickbooks' } }
61
+
62
+ its(:password) { should eq 'quickbooks' }
63
+
64
+ after { QuickbooksWebConnector.configure { |c| c.password = 'secret' } }
65
+ end
66
+ end
67
+
68
+ context 'company_file_path' do
69
+
70
+ context 'by default' do
71
+ its(:company_file_path) { should eq '' }
72
+ end
73
+
74
+ context 'configured via a config block' do
75
+ before { QuickbooksWebConnector.configure { |c| c.company_file_path = '/path/to/company.qbw' } }
76
+
77
+ its(:company_file_path) { should eq '/path/to/company.qbw' }
78
+
79
+ after { QuickbooksWebConnector.configure { |c| c.company_file_path = '' } }
80
+ end
81
+ end
82
+
83
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe QuickbooksWebConnector::QwcController do
4
+
5
+ describe 'GET :download' do
6
+ before { get :download, format: :xml, use_route: 'quickbooks_web_connector' }
7
+
8
+ it 'responds with success' do
9
+ expect(response).to be_success
10
+ end
11
+
12
+ it 'responds as XML' do
13
+ expect(response.header['Content-Type']).to match(/application\/xml/)
14
+ end
15
+
16
+ it 'sends the file as an attachment' do
17
+ expect(response.header['Content-Disposition']).to match(/attachment/)
18
+ end
19
+
20
+ it 'names the file' do
21
+ expect(response.header['Content-Disposition']).to match(/qbwc\.qwc/)
22
+ end
23
+
24
+ it 'renders the qwc template' do
25
+ assert_template :qwc
26
+ end
27
+ end
28
+
29
+ end