quake_timesheets_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/GENERATING_README.md +17 -0
  3. data/Gemfile +9 -0
  4. data/README.md +161 -0
  5. data/Rakefile +10 -0
  6. data/build.sh +10 -0
  7. data/commands +13 -0
  8. data/docs/Approval.md +34 -0
  9. data/docs/ApprovalType.md +24 -0
  10. data/docs/ApprovalTypesApi.md +153 -0
  11. data/docs/ApprovalsApi.md +153 -0
  12. data/docs/Dataset.md +24 -0
  13. data/docs/DatasetsApi.md +214 -0
  14. data/docs/EntriesApi.md +251 -0
  15. data/docs/Entry.md +36 -0
  16. data/docs/PeopleApi.md +151 -0
  17. data/docs/Person.md +22 -0
  18. data/git_push.sh +58 -0
  19. data/lib/quake_timesheets_client.rb +58 -0
  20. data/lib/quake_timesheets_client/api/approval_types_api.rb +158 -0
  21. data/lib/quake_timesheets_client/api/approvals_api.rb +174 -0
  22. data/lib/quake_timesheets_client/api/datasets_api.rb +202 -0
  23. data/lib/quake_timesheets_client/api/entries_api.rb +253 -0
  24. data/lib/quake_timesheets_client/api/people_api.rb +151 -0
  25. data/lib/quake_timesheets_client/api_client.rb +396 -0
  26. data/lib/quake_timesheets_client/api_error.rb +57 -0
  27. data/lib/quake_timesheets_client/configuration.rb +302 -0
  28. data/lib/quake_timesheets_client/models/approval.rb +378 -0
  29. data/lib/quake_timesheets_client/models/approval_type.rb +269 -0
  30. data/lib/quake_timesheets_client/models/dataset.rb +268 -0
  31. data/lib/quake_timesheets_client/models/entry.rb +361 -0
  32. data/lib/quake_timesheets_client/models/person.rb +254 -0
  33. data/lib/quake_timesheets_client/version.rb +24 -0
  34. data/quake_timesheets_client.gemspec +38 -0
  35. data/ruby-templates/README.mustache +187 -0
  36. data/ruby-templates/api_client.mustache +263 -0
  37. data/ruby-templates/api_client_faraday_partial.mustache +140 -0
  38. data/ruby-templates/configuration.mustache +379 -0
  39. data/ruby-templates/gem.mustache +59 -0
  40. data/ruby-templates/version.mustache +16 -0
  41. data/ruby.config.yaml +10 -0
  42. data/spec/api/approval_types_api_spec.rb +59 -0
  43. data/spec/api/approvals_api_spec.rb +60 -0
  44. data/spec/api/datasets_api_spec.rb +67 -0
  45. data/spec/api/entries_api_spec.rb +82 -0
  46. data/spec/api/people_api_spec.rb +58 -0
  47. data/spec/api_client_spec.rb +188 -0
  48. data/spec/configuration_spec.rb +42 -0
  49. data/spec/models/approval_spec.rb +86 -0
  50. data/spec/models/approval_type_spec.rb +52 -0
  51. data/spec/models/dataset_spec.rb +52 -0
  52. data/spec/models/entry_spec.rb +92 -0
  53. data/spec/models/person_spec.rb +46 -0
  54. data/spec/spec_helper.rb +111 -0
  55. metadata +149 -0
@@ -0,0 +1,59 @@
1
+ =begin
2
+ {{> api_info}}
3
+ =end
4
+
5
+ # Pre-define base modules
6
+ '{{moduleName}}'.split('::').reduce(Object) do |previous, mod|
7
+ if previous.const_defined?(mod.to_sym)
8
+ previous.const_get(mod.to_sym)
9
+ else
10
+ previous.const_set(mod.to_sym, Module.new)
11
+ end
12
+ end
13
+
14
+ # Common files
15
+ require '{{gemName}}/api_client'
16
+ require '{{gemName}}/api_error'
17
+ require '{{gemName}}/version'
18
+ require '{{gemName}}/configuration'
19
+
20
+ # Models
21
+ {{#models}}
22
+ {{#model}}
23
+ {{^parent}}
24
+ require '{{gemName}}/{{modelPackage}}/{{classFilename}}'
25
+ {{/parent}}
26
+ {{/model}}
27
+ {{/models}}
28
+ {{#models}}
29
+ {{#model}}
30
+ {{#parent}}
31
+ require '{{gemName}}/{{modelPackage}}/{{classFilename}}'
32
+ {{/parent}}
33
+ {{/model}}
34
+ {{/models}}
35
+
36
+ # APIs
37
+ {{#apiInfo}}
38
+ {{#apis}}
39
+ require '{{importPath}}'
40
+ {{/apis}}
41
+ {{/apiInfo}}
42
+
43
+ module {{moduleName}}
44
+ class << self
45
+ # Customize default settings for the SDK using block.
46
+ # {{moduleName}}.configure do |config|
47
+ # config.username = "xxx"
48
+ # config.password = "xxx"
49
+ # end
50
+ # If no block given, return the default Configuration object.
51
+ def configure
52
+ if block_given?
53
+ yield(Configuration.default)
54
+ else
55
+ Configuration.default
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,16 @@
1
+ =begin
2
+ {{> api_info}}
3
+ =end
4
+
5
+ # Pre-define base modules
6
+ '{{moduleName}}'.split('::').reduce(Object) do |previous, mod|
7
+ if previous.const_defined?(mod.to_sym)
8
+ previous.const_get(mod.to_sym)
9
+ else
10
+ previous.const_set(mod.to_sym, Module.new)
11
+ end
12
+ end
13
+
14
+ module {{moduleName}}
15
+ VERSION = '{{gemVersion}}'
16
+ end
data/ruby.config.yaml ADDED
@@ -0,0 +1,10 @@
1
+ ---
2
+ gemName: "quake_timesheets_client"
3
+ gemHomepage: https://www.quake.co.uk
4
+ gemSummary: A client for the Quake Timesheets API
5
+ gemDescription: Requires the Quake Timesheets system
6
+ gemLicense: MIT
7
+ gemVersion: 0.1.0
8
+ gemRequiredRubyVersion: ">= 2.7"
9
+ library: faraday
10
+ moduleName: Quake::Timesheets
@@ -0,0 +1,59 @@
1
+ =begin
2
+ #TimesheetsApi (params in:formData)
3
+
4
+ # <p>Another API description</p>
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Quake::Timesheets::ApprovalTypesApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'ApprovalTypesApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = Quake::Timesheets::ApprovalTypesApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of ApprovalTypesApi' do
30
+ it 'should create an instance of ApprovalTypesApi' do
31
+ expect(@api_instance).to be_instance_of(Quake::Timesheets::ApprovalTypesApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for get_api_v1_approval_types
36
+ # Search for approval types matching filters
37
+ # @param [Hash] opts the optional parameters
38
+ # @option opts [String] :dataset_id Filter to the approval types belonging to one of the identified datasets
39
+ # @return [Array<ApprovalType>]
40
+ describe 'get_api_v1_approval_types test' do
41
+ it 'should work' do
42
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
43
+ end
44
+ end
45
+
46
+ # unit tests for post_api_v1_approval_types
47
+ # Create a new Approval Type
48
+ # @param weight The weight provided by approvals of this type
49
+ # @param name The name of the approval type
50
+ # @param dataset_id ID of the dataset this approval type is linked to
51
+ # @param [Hash] opts the optional parameters
52
+ # @return [ApprovalType]
53
+ describe 'post_api_v1_approval_types test' do
54
+ it 'should work' do
55
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,60 @@
1
+ =begin
2
+ #TimesheetsApi (params in:formData)
3
+
4
+ # <p>Another API description</p>
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Quake::Timesheets::ApprovalsApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'ApprovalsApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = Quake::Timesheets::ApprovalsApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of ApprovalsApi' do
30
+ it 'should create an instance of ApprovalsApi' do
31
+ expect(@api_instance).to be_instance_of(Quake::Timesheets::ApprovalsApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for get_api_v1_approvals
36
+ # Search for approval types matching filters
37
+ # @param dataset_id Filter to the approvals belonging to one of the identified datasets
38
+ # @param [Hash] opts the optional parameters
39
+ # @return [Array<Approval>]
40
+ describe 'get_api_v1_approvals test' do
41
+ it 'should work' do
42
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
43
+ end
44
+ end
45
+
46
+ # unit tests for post_api_v1_approvals
47
+ # Create a new Approval
48
+ # @param state
49
+ # @param approval_type_id The ID of the Approval Type of this Approval
50
+ # @param entry_id The ID of the Entry this Approval is linked to
51
+ # @param dataset_id ID of the dataset this approval type is linked to
52
+ # @param [Hash] opts the optional parameters
53
+ # @return [Approval]
54
+ describe 'post_api_v1_approvals test' do
55
+ it 'should work' do
56
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,67 @@
1
+ =begin
2
+ #TimesheetsApi (params in:formData)
3
+
4
+ # <p>Another API description</p>
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Quake::Timesheets::DatasetsApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'DatasetsApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = Quake::Timesheets::DatasetsApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of DatasetsApi' do
30
+ it 'should create an instance of DatasetsApi' do
31
+ expect(@api_instance).to be_instance_of(Quake::Timesheets::DatasetsApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for get_api_v1_datasets
36
+ # List all available datasets
37
+ # @param [Hash] opts the optional parameters
38
+ # @return [Array<Dataset>]
39
+ describe 'get_api_v1_datasets test' do
40
+ it 'should work' do
41
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
42
+ end
43
+ end
44
+
45
+ # unit tests for get_api_v1_datasets_id
46
+ # Show details about a specific dataset
47
+ # @param id ID of the dataset
48
+ # @param [Hash] opts the optional parameters
49
+ # @return [Dataset]
50
+ describe 'get_api_v1_datasets_id test' do
51
+ it 'should work' do
52
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
53
+ end
54
+ end
55
+
56
+ # unit tests for post_api_v1_datasets
57
+ # Create a new Dataset record
58
+ # @param name Name for the Dataset object
59
+ # @param [Hash] opts the optional parameters
60
+ # @return [Dataset]
61
+ describe 'post_api_v1_datasets test' do
62
+ it 'should work' do
63
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
64
+ end
65
+ end
66
+
67
+ end
@@ -0,0 +1,82 @@
1
+ =begin
2
+ #TimesheetsApi (params in:formData)
3
+
4
+ # <p>Another API description</p>
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Quake::Timesheets::EntriesApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'EntriesApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = Quake::Timesheets::EntriesApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of EntriesApi' do
30
+ it 'should create an instance of EntriesApi' do
31
+ expect(@api_instance).to be_instance_of(Quake::Timesheets::EntriesApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for get_api_v1_entries
36
+ # Search for entries matching filters
37
+ # @param [Hash] opts the optional parameters
38
+ # @option opts [String] :dataset_id Filter to the entries belonging to one of the identified datasets
39
+ # @option opts [String] :person_id Filter to the entries belonging to one of the identified people
40
+ # @option opts [String] :from_date Return only entries after this DateTime (inclusive)
41
+ # @option opts [String] :to_date Return only entries before this DateTime (inclusive)
42
+ # @return [Array<Entry>]
43
+ describe 'get_api_v1_entries test' do
44
+ it 'should work' do
45
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
46
+ end
47
+ end
48
+
49
+ # unit tests for post_api_v1_entries
50
+ # Create a new Entry
51
+ # @param [Hash] opts the optional parameters
52
+ # @option opts [String] :person_id ID of the person to which this entry pertains
53
+ # @option opts [String] :start_at Time period at which this entry starts
54
+ # @option opts [String] :end_at Time period at which this entry ends
55
+ # @option opts [Float] :quantity
56
+ # @option opts [String] :unit
57
+ # @option opts [String] :external_reference Unique identifier of the activity this Entry relates to
58
+ # @return [Entry]
59
+ describe 'post_api_v1_entries test' do
60
+ it 'should work' do
61
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
62
+ end
63
+ end
64
+
65
+ # unit tests for post_api_v1_entries_id
66
+ # Update an existing Entry
67
+ # @param id The ID for the Entry
68
+ # @param [Hash] opts the optional parameters
69
+ # @option opts [String] :person_id ID of the person to which this entry pertains
70
+ # @option opts [String] :start_at Time period at which this entry starts
71
+ # @option opts [String] :end_at Time period at which this entry ends
72
+ # @option opts [Float] :quantity
73
+ # @option opts [String] :unit
74
+ # @option opts [String] :external_reference Unique identifier of the activity this Entry relates to
75
+ # @return [Entry]
76
+ describe 'post_api_v1_entries_id test' do
77
+ it 'should work' do
78
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
79
+ end
80
+ end
81
+
82
+ end
@@ -0,0 +1,58 @@
1
+ =begin
2
+ #TimesheetsApi (params in:formData)
3
+
4
+ # <p>Another API description</p>
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Quake::Timesheets::PeopleApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'PeopleApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = Quake::Timesheets::PeopleApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of PeopleApi' do
30
+ it 'should create an instance of PeopleApi' do
31
+ expect(@api_instance).to be_instance_of(Quake::Timesheets::PeopleApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for get_api_v1_people
36
+ # Search for people matching filters
37
+ # @param [Hash] opts the optional parameters
38
+ # @option opts [String] :dataset_id Filter to the people belonging to one of the identified datasets
39
+ # @return [Array<Person>]
40
+ describe 'get_api_v1_people test' do
41
+ it 'should work' do
42
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
43
+ end
44
+ end
45
+
46
+ # unit tests for post_api_v1_people
47
+ # Create a new Person record
48
+ # @param name Human readable name for the Person object (usually the subject&#39;s real name)
49
+ # @param dataset_id Dataset to which the Person object should belong
50
+ # @param [Hash] opts the optional parameters
51
+ # @return [Person]
52
+ describe 'post_api_v1_people test' do
53
+ it 'should work' do
54
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,188 @@
1
+ =begin
2
+ #TimesheetsApi (params in:formData)
3
+
4
+ # <p>Another API description</p>
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe Quake::Timesheets::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ Quake::Timesheets.configure { |c| c.host = 'http://example.com' }
21
+ expect(Quake::Timesheets::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ Quake::Timesheets.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(Quake::Timesheets::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ Quake::Timesheets.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(Quake::Timesheets::Configuration.default.host).to eq('hobo.com')
32
+ end
33
+ end
34
+
35
+ context 'base_path' do
36
+ it "prepends a slash to base_path" do
37
+ Quake::Timesheets.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(Quake::Timesheets::Configuration.default.base_path).to eq('/v4/dog')
39
+ end
40
+
41
+ it "doesn't prepend a slash if one is already there" do
42
+ Quake::Timesheets.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(Quake::Timesheets::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ Quake::Timesheets.configure { |c| c.base_path = nil }
48
+ expect(Quake::Timesheets::Configuration.default.base_path).to eq('')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe '#deserialize' do
55
+ it "handles Array<Integer>" do
56
+ api_client = Quake::Timesheets::ApiClient.new
57
+ headers = { 'Content-Type' => 'application/json' }
58
+ response = double('response', headers: headers, body: '[12, 34]')
59
+ data = api_client.deserialize(response, 'Array<Integer>')
60
+ expect(data).to be_instance_of(Array)
61
+ expect(data).to eq([12, 34])
62
+ end
63
+
64
+ it 'handles Array<Array<Integer>>' do
65
+ api_client = Quake::Timesheets::ApiClient.new
66
+ headers = { 'Content-Type' => 'application/json' }
67
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
68
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
69
+ expect(data).to be_instance_of(Array)
70
+ expect(data).to eq([[12, 34], [56]])
71
+ end
72
+
73
+ it 'handles Hash<String, String>' do
74
+ api_client = Quake::Timesheets::ApiClient.new
75
+ headers = { 'Content-Type' => 'application/json' }
76
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
77
+ data = api_client.deserialize(response, 'Hash<String, String>')
78
+ expect(data).to be_instance_of(Hash)
79
+ expect(data).to eq(:message => 'Hello')
80
+ end
81
+ end
82
+
83
+ describe "#object_to_hash" do
84
+ it 'ignores nils and includes empty arrays' do
85
+ # uncomment below to test object_to_hash for model
86
+ # api_client = Quake::Timesheets::ApiClient.new
87
+ # _model = Quake::Timesheets::ModelName.new
88
+ # update the model attribute below
89
+ # _model.id = 1
90
+ # update the expected value (hash) below
91
+ # expected = {id: 1, name: '', tags: []}
92
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
93
+ end
94
+ end
95
+
96
+ describe '#build_collection_param' do
97
+ let(:param) { ['aa', 'bb', 'cc'] }
98
+ let(:api_client) { Quake::Timesheets::ApiClient.new }
99
+
100
+ it 'works for csv' do
101
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
102
+ end
103
+
104
+ it 'works for ssv' do
105
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
106
+ end
107
+
108
+ it 'works for tsv' do
109
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
110
+ end
111
+
112
+ it 'works for pipes' do
113
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
114
+ end
115
+
116
+ it 'works for multi' do
117
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
118
+ end
119
+
120
+ it 'fails for invalid collection format' do
121
+ expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
122
+ end
123
+ end
124
+
125
+ describe '#json_mime?' do
126
+ let(:api_client) { Quake::Timesheets::ApiClient.new }
127
+
128
+ it 'works' do
129
+ expect(api_client.json_mime?(nil)).to eq false
130
+ expect(api_client.json_mime?('')).to eq false
131
+
132
+ expect(api_client.json_mime?('application/json')).to eq true
133
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
134
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
135
+
136
+ expect(api_client.json_mime?('application/xml')).to eq false
137
+ expect(api_client.json_mime?('text/plain')).to eq false
138
+ expect(api_client.json_mime?('application/jsonp')).to eq false
139
+ end
140
+ end
141
+
142
+ describe '#select_header_accept' do
143
+ let(:api_client) { Quake::Timesheets::ApiClient.new }
144
+
145
+ it 'works' do
146
+ expect(api_client.select_header_accept(nil)).to be_nil
147
+ expect(api_client.select_header_accept([])).to be_nil
148
+
149
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
150
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
151
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
152
+
153
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
154
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
155
+ end
156
+ end
157
+
158
+ describe '#select_header_content_type' do
159
+ let(:api_client) { Quake::Timesheets::ApiClient.new }
160
+
161
+ it 'works' do
162
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
163
+ expect(api_client.select_header_content_type([])).to eq('application/json')
164
+
165
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
166
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
167
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
168
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
169
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
170
+ end
171
+ end
172
+
173
+ describe '#sanitize_filename' do
174
+ let(:api_client) { Quake::Timesheets::ApiClient.new }
175
+
176
+ it 'works' do
177
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
178
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
179
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
180
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
181
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
182
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
183
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
184
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
185
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
186
+ end
187
+ end
188
+ end