lws 7.1.1 → 7.2.1

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.
@@ -0,0 +1,80 @@
1
+ #
2
+ # Copyright © 2016–2020 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: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
+
11
+
12
+ require "test_helper"
13
+
14
+ class TestHTTPCaching < MiniTest::Test
15
+
16
+ # Class used to check if data is read/written to or remove from the cache
17
+ class HTTPCacheTest
18
+
19
+ attr_reader :last_read_key
20
+ attr_reader :last_written_key, :last_written_value
21
+ attr_reader :last_deleted_key
22
+
23
+ def read(key)
24
+ @last_read_key = key
25
+ nil
26
+ end
27
+
28
+ def write(key, value)
29
+ @last_written_key = key
30
+ @last_written_value = value
31
+ nil
32
+ end
33
+
34
+ def delete(key)
35
+ @last_deleted_key = key
36
+ nil
37
+ end
38
+
39
+ end
40
+
41
+ def setup
42
+ @cache_mock = HTTPCacheTest.new
43
+
44
+ # Redo the LWS setup with an HTTP caching object
45
+ LWS.setup do |config|
46
+ config.api_token = ENV["LC_LWS_TEST_TOKEN"]
47
+ config.http_caching_object = @cache_mock
48
+ if ENV["LC_LWS_TEST_DEBUG"].present?
49
+ config.http_debug = true
50
+ config.http_debug_headers = true
51
+ end
52
+ config.environment = :development
53
+ end
54
+ end
55
+
56
+ def teardown
57
+ # Restore the configuration
58
+ reconfigure
59
+ end
60
+
61
+ def test_working_cache
62
+ assert_nil(@cache_mock.last_read_key)
63
+ assert_nil(@cache_mock.last_written_key)
64
+ assert_nil(@cache_mock.last_written_value)
65
+ assert_nil(@cache_mock.last_deleted_key)
66
+
67
+ new_configuration = LWS::Auth::Configuration.create(key: "test", value: "some_value")
68
+ refute_nil(@cache_mock.last_deleted_key)
69
+
70
+ _configurations = LWS::Auth::Configuration.where(key: "test").to_a
71
+ refute_nil(@cache_mock.last_read_key)
72
+ assert_equal(@cache_mock.last_read_key, @cache_mock.last_written_key)
73
+ refute_nil(@cache_mock.last_written_value)
74
+
75
+ old_key = @cache_mock.last_deleted_key.dup
76
+ new_configuration.destroy
77
+ refute_equal(old_key, @cache_mock.last_deleted_key)
78
+ end
79
+
80
+ end
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  require "test_helper"
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  require "test_helper"
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  require "test_helper"
@@ -16,7 +16,7 @@ class TestMapsMap < MiniTest::Test
16
16
  include LWS::Maps
17
17
 
18
18
  def setup
19
- @map = Map.all.first
19
+ @map = Map.find(1)
20
20
  end
21
21
 
22
22
  def test_valid_map
@@ -37,7 +37,7 @@ class TestMapsMarker < MiniTest::Test
37
37
  include LWS::Maps
38
38
 
39
39
  def setup
40
- @map = Map.all.first
40
+ @map = Map.find(1)
41
41
  # Markers only exist as child objects of maps
42
42
  @marker = @map.markers.first
43
43
  end
@@ -60,7 +60,7 @@ class TestMapsSource < MiniTest::Test
60
60
  include LWS::Maps
61
61
 
62
62
  def setup
63
- @source = Source.all.first
63
+ @source = Source.find(1)
64
64
  end
65
65
 
66
66
  def test_valid_source
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  require "test_helper"
@@ -35,6 +35,29 @@ class TestPresenceAppointment < MiniTest::Test
35
35
 
36
36
  end
37
37
 
38
+ class TestPresenceJournal < MiniTest::Test
39
+ include LWS::Presence
40
+
41
+ def setup
42
+ @location = Location.find(1)
43
+ # Journals only exist as child objects of a location
44
+ @journal = @location.journals.first
45
+ end
46
+
47
+ def test_valid
48
+ refute_nil(@journal)
49
+ assert_instance_of(Journal, @journal)
50
+ refute_nil(@journal.id)
51
+ end
52
+
53
+ def test_valid_associations
54
+ assert_instance_of(LWS::Auth::Company, @journal.company)
55
+ assert_instance_of(Location, @journal.location)
56
+ assert_equal(@location, @journal.location)
57
+ assert_instance_of(Person, @journal.person)
58
+ end
59
+ end
60
+
38
61
  class TestPresenceLocation < MiniTest::Test
39
62
 
40
63
  include LWS::Presence
@@ -165,7 +188,7 @@ class TestPresenceReader < MiniTest::Test
165
188
  include LWS::Presence
166
189
 
167
190
  def setup
168
- @reader = Reader.all.first
191
+ @reader = Reader.find(1)
169
192
  end
170
193
 
171
194
  def test_valid
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  require "test_helper"
@@ -25,7 +25,7 @@ class TestResourceCollection < MiniTest::Test
25
25
  include LWS::Resource
26
26
 
27
27
  def setup
28
- @collection = Collection.all.first # FIXME
28
+ @collection = Collection.find(1)
29
29
  end
30
30
 
31
31
  def test_valid
@@ -48,7 +48,7 @@ class TestResourceCollectionItem < MiniTest::Test
48
48
  include LWS::Resource
49
49
 
50
50
  def setup
51
- @collection = Collection.where(includes: "items").first # FIXME
51
+ @collection = Collection.where(includes: "items").find(1)
52
52
  @collection_item = @collection.items.first
53
53
  end
54
54
 
@@ -70,7 +70,7 @@ class TestResourceFolder < MiniTest::Test
70
70
  include LWS::Resource
71
71
 
72
72
  def setup
73
- @folder = Folder.all.first
73
+ @folder = Folder.find(1)
74
74
  end
75
75
 
76
76
  def test_valid
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  require "test_helper"
@@ -71,7 +71,6 @@ class TestSetup < MiniTest::Test
71
71
 
72
72
  def test_load_config_files
73
73
  orig_config = LWS.config.dup
74
-
75
74
  reconfigure do |config|
76
75
  assert config.load_config_file(File.join(@test_config_dir, "empty.yml"))
77
76
  end
@@ -113,6 +112,20 @@ class TestSetup < MiniTest::Test
113
112
  assert_equal(true, LWS.config.http_debug)
114
113
  assert_equal(true, LWS.config.http_debug_headers)
115
114
  assert_equal(true, LWS.config.json_debug)
115
+
116
+ with_env("LC_LWS_ENV" => "production") do
117
+ reconfigure do |config|
118
+ assert config.load_config_file(File.join(@test_config_dir, "empty.yml"),
119
+ :development)
120
+ end
121
+ assert_equal(:development, LWS.config.environment)
122
+ end
123
+
124
+ reconfigure do |config|
125
+ assert config.load_config_file(File.join(@test_config_dir, "switch_env.yml"),
126
+ :development)
127
+ end
128
+ assert_equal(:development, LWS.config.environment)
116
129
  end
117
130
 
118
131
  end
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  require "test_helper"
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  class Minitest::Test
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  require 'simplecov'
@@ -49,14 +49,18 @@ raise "Test token not set" if ENV["LC_LWS_TEST_TOKEN"].blank?
49
49
 
50
50
  def reconfigure(options = {}, &block)
51
51
  LWS.setup do |config|
52
- config.api_token = ENV["LC_LWS_TEST_TOKEN"]
52
+ if ENV["LC_LWS_API_TOKEN"].blank?
53
+ config.api_token = ENV["LC_LWS_TEST_TOKEN"]
54
+ end
53
55
  if ENV["LC_LWS_TEST_DEBUG"].present?
54
56
  config.logger = Logger.new($stdout)
55
57
  config.http_debug = true
56
58
  config.http_debug_headers = false
57
59
  config.json_debug = true
58
60
  end
59
- config.environment = :development
61
+ if ENV["LC_LWS_ENV"].blank?
62
+ config.environment = :development
63
+ end
60
64
 
61
65
  # Override the config with the given options.
62
66
  options.each do |key, value|
@@ -1,12 +1,12 @@
1
1
  #
2
- # Copyright © 2016 LeftClick B.V.
2
+ # Copyright © 2016–2020 LeftClick B.V.
3
3
  #
4
4
  # This software is property of LeftClick B.V. and cannot be redistributed
5
5
  # and/or modified without permission. The software or any of its parts
6
6
  # cannot be used for any other purposes than the LeftClick services and
7
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.
8
+ # contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
9
+ # Netherlands, info@leftclick.eu, +3185-4444-004.
10
10
 
11
11
 
12
12
  require "test_helper"
@@ -40,7 +40,7 @@ class TestTicketGroup < MiniTest::Test
40
40
  include LWS::Ticket
41
41
 
42
42
  def setup
43
- @group = Group.all.first
43
+ @group = Group.find(1)
44
44
  end
45
45
 
46
46
  def test_valid
@@ -88,7 +88,7 @@ class TestTicketTag < MiniTest::Test
88
88
  include LWS::Ticket
89
89
 
90
90
  def setup
91
- @tag = Tag.all.first
91
+ @tag = Tag.find(1)
92
92
  end
93
93
 
94
94
  def test_valid_tag
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lws
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.1
4
+ version: 7.2.1
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: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2020-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday-http-cache
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.2'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: faraday_middleware
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -262,6 +276,7 @@ files:
262
276
  - test/fixtures/auth.yml
263
277
  - test/fixtures/permissions.yml
264
278
  - test/generic_test.rb
279
+ - test/http_caching_test.rb
265
280
  - test/json_parser_test.rb
266
281
  - test/logger_test.rb
267
282
  - test/maps_test.rb
@@ -290,33 +305,33 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
305
  - !ruby/object:Gem::Version
291
306
  version: '0'
292
307
  requirements: []
293
- rubyforge_project:
294
- rubygems_version: 2.7.6
308
+ rubygems_version: 3.1.2
295
309
  signing_key:
296
310
  specification_version: 4
297
311
  summary: LeftClick web services library for Ruby
298
312
  test_files:
299
- - test/support/with_env.rb
300
- - test/json_parser_test.rb
301
- - test/test_helper.rb
302
- - test/setup_test.rb
303
- - test/ticket_test.rb
304
- - test/api_token_middleware_test.rb
305
- - test/stubbing_test.rb
306
- - test/presence_test.rb
307
- - test/digital_signage_test.rb
313
+ - test/http_caching_test.rb
308
314
  - test/generic_test.rb
309
- - test/logger_test.rb
310
- - test/auth_test.rb
311
- - test/resource_test.rb
312
- - test/maps_test.rb
315
+ - test/caching_test.rb
316
+ - test/api_token_middleware_test.rb
313
317
  - test/corporate_website_test.rb
314
- - test/config/tokens.yml
318
+ - test/ticket_test.rb
319
+ - test/stubbing_test.rb
320
+ - test/setup_test.rb
321
+ - test/config/invalid.yml
322
+ - test/config/full.yml
315
323
  - test/config/empty.yml
316
324
  - test/config/endpoints.yml
317
- - test/config/invalid.yml
318
325
  - test/config/switch_env.yml
319
- - test/config/full.yml
320
- - test/caching_test.rb
321
- - test/fixtures/auth.yml
326
+ - test/config/tokens.yml
327
+ - test/json_parser_test.rb
328
+ - test/presence_test.rb
329
+ - test/digital_signage_test.rb
330
+ - test/test_helper.rb
331
+ - test/maps_test.rb
332
+ - test/support/with_env.rb
333
+ - test/resource_test.rb
334
+ - test/auth_test.rb
335
+ - test/logger_test.rb
322
336
  - test/fixtures/permissions.yml
337
+ - test/fixtures/auth.yml