lws 0.4.2 → 6.1.0.beta1

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.
@@ -16,7 +16,10 @@ auth:
16
16
  user_id: null
17
17
 
18
18
  /tokens/does_not_exist:
19
- default: {}
19
+ default:
20
+ errors:
21
+ base:
22
+ - "Not found (HTTP 404)"
20
23
 
21
24
  /tokens:
22
25
  default:
@@ -8,10 +8,6 @@ auth:
8
8
  value: "true"
9
9
  - key: configuration.write
10
10
  value: "true"
11
- - key: task.read
12
- value: "true"
13
- - key: task.write
14
- value: "true"
15
11
  generic:
16
12
  - id: 1
17
13
  app_key: test
data/test/generic_test.rb CHANGED
@@ -28,20 +28,3 @@ class TestGenericConfiguration < MiniTest::Test
28
28
  #end
29
29
 
30
30
  end
31
-
32
- class TestGenericTask < MiniTest::Test
33
-
34
- # Generic class needs to be accessed under some kind of app
35
- include LWS::Auth
36
-
37
- def setup
38
- @task = Task.all.first
39
- end
40
-
41
- def test_valid_task
42
- refute_nil(@task)
43
- assert_instance_of(Task, @task)
44
- refute_nil(@task.id)
45
- end
46
-
47
- end
@@ -0,0 +1,57 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
11
+
12
+ require "test_helper"
13
+
14
+ class TestJSONParser < MiniTest::Test
15
+
16
+ include WebMock::API
17
+
18
+ def setup
19
+ WebMock.enable!
20
+ company = { id: "correct",
21
+ country: "NL",
22
+ # ...
23
+ }
24
+
25
+ full_uri = LWS::Auth.api.url_prefix.dup
26
+ full_uri.path = "/companies/broken"
27
+ stub_request(:get, full_uri.to_s).to_return(body: "{}invalid json")
28
+ full_uri.path = "/companies/correct"
29
+ stub_request(:get, full_uri.to_s)
30
+ .to_return(body: MultiJson.dump(company))
31
+ stub_request(:put, full_uri.to_s)
32
+ .to_return(body: MultiJson.dump(company.merge(errors: { ticket: ["is an invalid field"] })))
33
+ end
34
+
35
+ def teardown
36
+ WebMock.disable!
37
+ end
38
+
39
+ def test_broken_json
40
+ assert_raises MultiJson::ParseError do
41
+ company = LWS::Auth::Company.find("broken")
42
+ end
43
+ end
44
+
45
+ def test_correct_json
46
+ company = LWS::Auth::Company.find("correct")
47
+ assert_equal "correct", company.id
48
+ end
49
+
50
+ def test_correct_json_with_errors
51
+ company = LWS::Auth::Company.find("correct")
52
+ company.ticket = "unknown attribute"
53
+ company.save
54
+ assert_equal ["Ticket is an invalid field"], company.errors.to_a
55
+ end
56
+
57
+ end
data/test/logger_test.rb CHANGED
@@ -21,10 +21,11 @@ class TestLogger < MiniTest::Test
21
21
  # Configure the logger and enable HTTP request and JSON data debugging
22
22
  reconfigure(logger: logger,
23
23
  http_debug: true,
24
+ http_debug_headers: true,
24
25
  json_debug: true)
25
26
 
26
27
  # Perform a query to have any log entries
27
- LWS::Auth::Task.all.first
28
+ LWS::Auth::Token.all.first
28
29
  refute_nil(log.string)
29
30
 
30
31
  # Restore the token
data/test/maps_test.rb CHANGED
@@ -32,7 +32,7 @@ class TestMapsMap < MiniTest::Test
32
32
 
33
33
  end
34
34
 
35
- class TestMapsMap < MiniTest::Test
35
+ class TestMapsMarker < MiniTest::Test
36
36
 
37
37
  include LWS::Maps
38
38
 
@@ -54,3 +54,24 @@ class TestMapsMap < MiniTest::Test
54
54
  end
55
55
 
56
56
  end
57
+
58
+ class TestMapsSource < MiniTest::Test
59
+
60
+ include LWS::Maps
61
+
62
+ def setup
63
+ @source = Source.all.first
64
+ end
65
+
66
+ def test_valid_source
67
+ refute_nil(@source)
68
+ assert_instance_of(Source, @source)
69
+ refute_nil(@source.id)
70
+ end
71
+
72
+ def test_valid_source_associations
73
+ # FIXME: Not implemented yet
74
+ #assert_instance_of(Map, @source.maps.first)
75
+ end
76
+
77
+ end
@@ -11,44 +11,44 @@
11
11
 
12
12
  require "test_helper"
13
13
 
14
- class TestPresencePerson < MiniTest::Test
14
+ class TestPresenceLocation < MiniTest::Test
15
15
 
16
16
  include LWS::Presence
17
17
 
18
18
  def setup
19
- @person = Person.all.first
19
+ @location = Location.all.first
20
20
  end
21
21
 
22
- def test_valid_person
23
- refute_nil(@person)
24
- assert_instance_of(Person, @person)
25
- refute_nil(@person.id)
22
+ def test_valid
23
+ refute_nil(@location)
24
+ assert_instance_of(Location, @location)
25
+ refute_nil(@location.id)
26
26
  end
27
27
 
28
- def test_valid_person_associations
29
- assert_instance_of(LWS::Auth::Company, @person.company)
30
- assert_instance_of(Location, @person.location)
28
+ def test_valid_associations
29
+ assert_instance_of(LWS::Auth::Company, @location.company)
30
+ assert_instance_of(Person, @location.people.first)
31
31
  end
32
32
 
33
33
  end
34
34
 
35
- class TestPresenceLocation < MiniTest::Test
35
+ class TestPresencePerson < MiniTest::Test
36
36
 
37
37
  include LWS::Presence
38
38
 
39
39
  def setup
40
- @location = Location.all.first
40
+ @person = Person.all.first
41
41
  end
42
42
 
43
- def test_valid_location
44
- refute_nil(@location)
45
- assert_instance_of(Location, @location)
46
- refute_nil(@location.id)
43
+ def test_valid
44
+ refute_nil(@person)
45
+ assert_instance_of(Person, @person)
46
+ refute_nil(@person.id)
47
47
  end
48
48
 
49
- def test_valid_location_associations
50
- assert_instance_of(LWS::Auth::Company, @location.company)
51
- assert_instance_of(Person, @location.people.first)
49
+ def test_valid_associations
50
+ assert_instance_of(LWS::Auth::Company, @person.company)
51
+ assert_instance_of(Location, @person.location)
52
52
  end
53
53
 
54
54
  end
data/test/setup_test.rb CHANGED
@@ -35,6 +35,11 @@ class TestSetup < MiniTest::Test
35
35
  end
36
36
  assert_equal(LWS.config.environment, :production)
37
37
 
38
+ with_env("LC_LWS_API_TOKEN" => "test-token") do
39
+ reconfigure
40
+ end
41
+ assert_equal(LWS.config.api_token, "test-token")
42
+
38
43
  # Restore the configuration
39
44
  reconfigure
40
45
  end
@@ -31,8 +31,10 @@ class TestStubbing < MiniTest::Test
31
31
  end
32
32
 
33
33
  def test_working_stubbing_with_status
34
- LWS.stubbing.replace(:get, :auth, "/tokens/does_not_exist", :default, 403)
35
- assert_nil LWS::Auth::Token.find("does_not_exist")
34
+ LWS.stubbing.replace(:get, :auth, "/tokens/does_not_exist", :default, 404)
35
+ assert_raises Spyke::ResourceNotFound do
36
+ LWS::Auth::Token.find("does_not_exist")
37
+ end
36
38
  end
37
39
 
38
40
  def test_replace_stub
data/test/test_helper.rb CHANGED
@@ -48,8 +48,9 @@ def reconfigure(options = {})
48
48
  config.api_token = ENV["LC_LWS_TEST_TOKEN"]
49
49
  if ENV["LC_LWS_TEST_DEBUG"].present?
50
50
  config.logger = Logger.new($stdout)
51
- config.http_debug = true
52
- config.json_debug = true
51
+ config.http_debug = false
52
+ config.http_debug_headers = false
53
+ config.json_debug = false
53
54
  end
54
55
  config.environment = :development
55
56
 
data/test/ticket_test.rb CHANGED
@@ -11,29 +11,47 @@
11
11
 
12
12
  require "test_helper"
13
13
 
14
- class TestTicketTicket < MiniTest::Test
14
+ # FIXME: Cannot reach an attachment through the API yet
15
+ #class TestTicketAttachment < MiniTest::Test
16
+ #
17
+ # include LWS::Ticket
18
+ #
19
+ # def setup
20
+ # @ticket = Ticket.find(1)
21
+ # @message = @ticket.messages.first
22
+ # @attachment = @message.attachments.first
23
+ # end
24
+ #
25
+ # def test_valid
26
+ # refute_nil(@attachment)
27
+ # assert_instance_of(Attachment, @attachment)
28
+ # refute_nil(@attachment.id)
29
+ # end
30
+ #
31
+ # def test_valid_associations
32
+ # assert_instance_of(Messsage, @attachment.message)
33
+ # assert_equal(@message, @attachment.message)
34
+ # end
35
+ #
36
+ #end
37
+
38
+ class TestTicketGroup < MiniTest::Test
15
39
 
16
40
  include LWS::Ticket
17
41
 
18
42
  def setup
19
- @ticket = Ticket.all.first
43
+ @group = Group.all.first
20
44
  end
21
45
 
22
- def test_valid_ticket
23
- refute_nil(@ticket)
24
- assert_instance_of(Ticket, @ticket)
25
- refute_nil(@ticket.id)
46
+ def test_valid
47
+ refute_nil(@group)
48
+ assert_instance_of(Group, @group)
49
+ refute_nil(@group.id)
26
50
  end
27
51
 
28
- def test_valid_ticket_associations
29
- assert_instance_of(LWS::Auth::Account, @ticket.account)
30
- assert_instance_of(LWS::Auth::Account, @ticket.assignee)
31
- assert_instance_of(LWS::Auth::Company, @ticket.company)
32
- assert_instance_of(Group, @ticket.group)
33
- assert_instance_of(Message, @ticket.messages.first)
34
- # FIXME: Enable when tags are reachable through the API
35
- #assert_instance_of(Tag, @ticket.tags.first)
36
- assert_instance_of(LWS::Auth::Company, @ticket.owner)
52
+ def test_valid_associations
53
+ # FIXME: Not implemented yet
54
+ #assert_instance_of(Ticket, @group.tickets.first)
37
55
  end
38
56
 
39
57
  end
@@ -43,7 +61,7 @@ class TestTicketMessage < MiniTest::Test
43
61
  include LWS::Ticket
44
62
 
45
63
  def setup
46
- @ticket = Ticket.all.first
64
+ @ticket = Ticket.find(1)
47
65
  # Messages only exist as child object of tickets
48
66
  @message = @ticket.messages.first
49
67
  end
@@ -56,60 +74,57 @@ class TestTicketMessage < MiniTest::Test
56
74
 
57
75
  def test_valid_message_associations
58
76
  assert_instance_of(LWS::Auth::Account, @message.account)
77
+ # FIXME: Cannot reach attachments through the API yet
78
+ #assert_instance_of(Attachment, @message.attachments.first)
59
79
  assert_instance_of(LWS::Auth::Company, @message.company)
60
- assert_instance_of(Ticket, @message.ticket)
80
+ assert_instance_of(Ticket, @message.ticket)
61
81
  assert_equal(@message.ticket, @ticket)
62
82
  end
63
83
 
64
84
  end
65
85
 
66
- class TestTicketAttachment < MiniTest::Test
67
-
68
- include LWS::Ticket
69
-
70
- # FIXME: Implement the tests once the attachments can be reached through
71
- # the API
72
-
73
- end
74
-
75
- class TestTicketGroup < MiniTest::Test
86
+ class TestTicketTag < MiniTest::Test
76
87
 
77
88
  include LWS::Ticket
78
89
 
79
90
  def setup
80
- @group = Group.all.first
91
+ @tag = Tag.all.first
81
92
  end
82
93
 
83
- def test_valid_group
84
- refute_nil(@group)
85
- assert_instance_of(Group, @group)
86
- refute_nil(@group.id)
94
+ def test_valid_tag
95
+ refute_nil(@tag)
96
+ assert_instance_of(Tag, @tag)
97
+ refute_nil(@tag.id)
87
98
  end
88
99
 
89
- def test_valid_message_associations
90
- # FIXME: Implement this test once tickets of a group and associated
91
- # accounts with a group can be reached through the API
100
+ def test_valid_tag_associations
101
+ assert_instance_of(Ticket, @tag.tickets.first)
92
102
  end
93
103
 
94
104
  end
95
105
 
96
- class TestTicketTag < MiniTest::Test
106
+ class TestTicketTicket < MiniTest::Test
97
107
 
98
108
  include LWS::Ticket
99
109
 
100
110
  def setup
101
- @tag = Tag.all.first
111
+ @ticket = Ticket.find(1)
102
112
  end
103
113
 
104
- def test_valid_tag
105
- refute_nil(@tag)
106
- assert_instance_of(Tag, @tag)
107
- refute_nil(@tag.id)
114
+ def test_valid_ticket
115
+ refute_nil(@ticket)
116
+ assert_instance_of(Ticket, @ticket)
117
+ refute_nil(@ticket.id)
108
118
  end
109
119
 
110
- def test_valid_tag_associations
111
- # FIXME: Enable when tags are reachable through the API
112
- #assert_instance_of(Ticket, @ticket)
120
+ def test_valid_ticket_associations
121
+ assert_instance_of(LWS::Auth::Account, @ticket.account)
122
+ assert_instance_of(LWS::Auth::Account, @ticket.assignee)
123
+ assert_instance_of(LWS::Auth::Company, @ticket.company)
124
+ assert_instance_of(Group, @ticket.group)
125
+ assert_instance_of(Message, @ticket.messages.first)
126
+ assert_instance_of(LWS::Auth::Company, @ticket.owner)
127
+ assert_instance_of(Tag, @ticket.tags.first)
113
128
  end
114
129
 
115
130
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 6.1.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LeftClick B.V.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-14 00:00:00.000000000 Z
11
+ date: 2017-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware
@@ -45,21 +45,21 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
- name: her
48
+ name: multi_json
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 0.8.2
53
+ version: '0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 0.8.2
60
+ version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
- name: multi_json
62
+ name: pry
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: spyke
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.5.1
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.5.1
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: webmock
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -120,20 +134,6 @@ dependencies:
120
134
  - - ">="
121
135
  - !ruby/object:Gem::Version
122
136
  version: '0'
123
- - !ruby/object:Gem::Dependency
124
- name: her
125
- requirement: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: 0.8.1
130
- type: :development
131
- prerelease: false
132
- version_requirements: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - "~>"
135
- - !ruby/object:Gem::Version
136
- version: 0.8.1
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: minitest
139
139
  requirement: !ruby/object:Gem::Requirement
@@ -204,6 +204,20 @@ dependencies:
204
204
  - - ">="
205
205
  - !ruby/object:Gem::Version
206
206
  version: '0'
207
+ - !ruby/object:Gem::Dependency
208
+ name: spyke
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - "~>"
212
+ - !ruby/object:Gem::Version
213
+ version: 0.5.1
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - "~>"
219
+ - !ruby/object:Gem::Version
220
+ version: 0.5.1
207
221
  description: |-
208
222
  This library for Ruby provides access to the LeftClick
209
223
  web services/applications using a model-based structure that abstracts from API calls
@@ -224,6 +238,7 @@ files:
224
238
  - lib/lws.rb
225
239
  - lib/lws/auth.rb
226
240
  - lib/lws/corporate_website.rb
241
+ - lib/lws/digital_signage.rb
227
242
  - lib/lws/generic.rb
228
243
  - lib/lws/maps.rb
229
244
  - lib/lws/presence.rb
@@ -235,9 +250,11 @@ files:
235
250
  - test/auth_test.rb
236
251
  - test/caching_test.rb
237
252
  - test/corporate_website_test.rb
253
+ - test/digital_signage_test.rb
238
254
  - test/fixtures/auth.yml
239
255
  - test/fixtures/permissions.yml
240
256
  - test/generic_test.rb
257
+ - test/json_parser_test.rb
241
258
  - test/logger_test.rb
242
259
  - test/maps_test.rb
243
260
  - test/presence_test.rb
@@ -260,9 +277,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
277
  version: '0'
261
278
  required_rubygems_version: !ruby/object:Gem::Requirement
262
279
  requirements:
263
- - - ">="
280
+ - - ">"
264
281
  - !ruby/object:Gem::Version
265
- version: '0'
282
+ version: 1.3.1
266
283
  requirements: []
267
284
  rubyforge_project:
268
285
  rubygems_version: 2.5.1
@@ -274,9 +291,11 @@ test_files:
274
291
  - test/auth_test.rb
275
292
  - test/caching_test.rb
276
293
  - test/corporate_website_test.rb
294
+ - test/digital_signage_test.rb
277
295
  - test/fixtures/auth.yml
278
296
  - test/fixtures/permissions.yml
279
297
  - test/generic_test.rb
298
+ - test/json_parser_test.rb
280
299
  - test/logger_test.rb
281
300
  - test/maps_test.rb
282
301
  - test/presence_test.rb