lws 7.0.2 → 7.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lwsconsole +9 -7
- data/lib/lws.rb +9 -8
- data/lib/lws/apps/digital_signage.rb +79 -96
- data/lib/lws/apps/generic.rb +76 -9
- data/lib/lws/apps/presence.rb +113 -2
- data/lib/lws/config.rb +23 -13
- data/lib/lws/version.rb +1 -1
- data/test/corporate_website_test.rb +5 -5
- data/test/digital_signage_test.rb +9 -70
- data/test/generic_test.rb +40 -4
- data/test/maps_test.rb +3 -3
- data/test/presence_test.rb +24 -1
- data/test/resource_test.rb +3 -3
- data/test/setup_test.rb +14 -1
- data/test/test_helper.rb +7 -3
- data/test/ticket_test.rb +2 -2
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b61e005e4e0e7bf19e2d9299e5444e914c5aac6df6cfd3084cd63ff5fd75bb87
|
4
|
+
data.tar.gz: 0fa6b75fa04c5b9823052e79a74283fcb1de031ca3312cd921f942100cb32248
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2619b5d60dc8a3df39b8d739b364832d63025b5eca9024b42619308e753ee51fcbd14dda437a1a1d3269eef2eee3e8acea30841c020b6bfc7da1b9dbd277af94
|
7
|
+
data.tar.gz: 97f62b08426cdbbeae331d10254f8b12e58147074cbecee642d1a4cbe179d4ebd1fd70080cda730d003ec10a2799499f626bc97d5ce92f3ab91189adb3d63d00
|
data/bin/lwsconsole
CHANGED
@@ -87,13 +87,11 @@ begin
|
|
87
87
|
if @options[:cfg_file]
|
88
88
|
cfg_file = @options[:cfg_file]
|
89
89
|
raise "config file does not exist: #{cfg_file}" unless File.exist? cfg_file
|
90
|
-
config.load_config_file(cfg_file)
|
90
|
+
config.load_config_file(cfg_file, @options[:environment])
|
91
91
|
else
|
92
|
-
config.load_config_file(GLOBAL_CONFIG_FILE)
|
93
|
-
config.load_config_file(USER_CONFIG_FILE)
|
92
|
+
config.load_config_file(GLOBAL_CONFIG_FILE, @options[:environment])
|
93
|
+
config.load_config_file(USER_CONFIG_FILE, @options[:environment])
|
94
94
|
end
|
95
|
-
|
96
|
-
config.environment = @options[:environment] if @options[:environment]
|
97
95
|
end
|
98
96
|
if @options[:app]
|
99
97
|
@app_module = LWS.app_module(@options[:app].downcase)
|
@@ -134,7 +132,11 @@ end
|
|
134
132
|
|
135
133
|
# Set up Pry
|
136
134
|
FileUtils.mkdir_p("#{ENV['HOME']}/.local/share/LeftClick")
|
137
|
-
Pry.config.
|
135
|
+
if Pry.config.history_file
|
136
|
+
Pry.config.history_file = "#{ENV['HOME']}/.local/share/LeftClick/lws_history"
|
137
|
+
else
|
138
|
+
Pry.config.history.file = "#{ENV['HOME']}/.local/share/LeftClick/lws_history"
|
139
|
+
end
|
138
140
|
Pry.config.prompt_name = PROG_NAME
|
139
141
|
|
140
142
|
# Print an LWS setup summary
|
@@ -154,7 +156,7 @@ if LWS.config.http_debug
|
|
154
156
|
end
|
155
157
|
end
|
156
158
|
debug_outputs << "JSON" if LWS.config.json_debug
|
157
|
-
|
159
|
+
if debug_outputs.present?
|
158
160
|
puts "- Debug output: #{debug_outputs.join(', ')}"
|
159
161
|
end
|
160
162
|
puts
|
data/lib/lws.rb
CHANGED
@@ -60,7 +60,7 @@ module LWS
|
|
60
60
|
# config.api_token_middleware = TokenAuthenticator
|
61
61
|
# config.caching_object = MyRedisCache.new
|
62
62
|
# config.environment = :development
|
63
|
-
# config.
|
63
|
+
# config.endpoints = { maps: "https://maps.leftclick.cloud" }
|
64
64
|
# config.http_debug = true
|
65
65
|
# config.json_debug = true
|
66
66
|
# config.logger = Rails.logger
|
@@ -77,7 +77,11 @@ module LWS
|
|
77
77
|
# @return [LWS] the module itself
|
78
78
|
def self.setup(&block)
|
79
79
|
@@config = Config.new
|
80
|
-
|
80
|
+
|
81
|
+
# Override the environment if needed
|
82
|
+
if ENV["LC_LWS_ENV"].present?
|
83
|
+
@@config.environment = ENV["LC_LWS_ENV"].to_sym
|
84
|
+
end
|
81
85
|
|
82
86
|
# Override the API token if needed (and no custom API token middleware
|
83
87
|
# is used)
|
@@ -85,10 +89,7 @@ module LWS
|
|
85
89
|
@@config.api_token = ENV["LC_LWS_API_TOKEN"]
|
86
90
|
end
|
87
91
|
|
88
|
-
|
89
|
-
if ENV["LC_LWS_ENV"].present?
|
90
|
-
@@config.environment = ENV["LC_LWS_ENV"].to_sym
|
91
|
-
end
|
92
|
+
yield @@config
|
92
93
|
|
93
94
|
if config.api_token.blank? and config.api_token_middleware.blank?
|
94
95
|
raise LWS::Errors::ConfigError,
|
@@ -107,8 +108,8 @@ module LWS
|
|
107
108
|
# Sets up the Faraday API object with the current LWS configuration for
|
108
109
|
# the given API URL.
|
109
110
|
#
|
110
|
-
# @param api_url The endpoint URL of the API
|
111
|
-
# @return [Faraday] A Faraday connection that makes requests to the API
|
111
|
+
# @param api_url [String] The endpoint URL of the API
|
112
|
+
# @return [Faraday::Connection] A Faraday connection that makes requests to the API
|
112
113
|
def self.setup_api(api_url)
|
113
114
|
api = Faraday.new(url: api_url) do |c|
|
114
115
|
# Request
|
@@ -497,6 +497,11 @@ module LWS::DigitalSignage
|
|
497
497
|
class Layout < LWS::Generic::Model
|
498
498
|
use_api LWS::DigitalSignage.api
|
499
499
|
|
500
|
+
# @!attribute category_ids
|
501
|
+
# @return [Array<Integer>] the IDs of the categories assoicated with
|
502
|
+
# the layout
|
503
|
+
attribute :category_ids
|
504
|
+
|
500
505
|
# @!attribute categories
|
501
506
|
# @return [Array<Layout::Category>] the categories associated with
|
502
507
|
# the layout
|
@@ -504,13 +509,19 @@ module LWS::DigitalSignage
|
|
504
509
|
has_many :categories, class_name: "LWS::DigitalSignage::Layout::Category",
|
505
510
|
uri: "layout/:layout_id/categories(/:id)"
|
506
511
|
|
507
|
-
# @!attribute
|
508
|
-
# @return [LWS::Auth::Company] the company the layout
|
509
|
-
belongs_to :
|
512
|
+
# @!attribute company_owner
|
513
|
+
# @return [LWS::Auth::Company] the company that owns the layout
|
514
|
+
belongs_to :company_owner, class_name: "LWS::Auth::Company",
|
515
|
+
foreign_key: :company_owner_id,
|
516
|
+
uri: "companies/:id"
|
510
517
|
|
511
|
-
# @!attribute
|
512
|
-
# @return [Integer] the ID of the company the layout
|
513
|
-
attribute :
|
518
|
+
# @!attribute company_owner_id
|
519
|
+
# @return [Integer] the ID of the company that owns the layout
|
520
|
+
attribute :company_owner_id
|
521
|
+
|
522
|
+
# @!attribute company_shared_ids
|
523
|
+
# @return [Array<Integer>] the IDs of the company the layout is shared with
|
524
|
+
attribute :company_shared_ids
|
514
525
|
|
515
526
|
# @!attribute default_duration
|
516
527
|
# @return [5..3600] the default duration of a slide created from the layout
|
@@ -520,6 +531,14 @@ module LWS::DigitalSignage
|
|
520
531
|
# @return [String, nil] the description of the layout
|
521
532
|
attribute :description
|
522
533
|
|
534
|
+
# @!attribute description_html
|
535
|
+
# @return [String, nil] an HTML version of the description of the layout
|
536
|
+
attribute :description_html
|
537
|
+
|
538
|
+
# @!attribute duration_kind
|
539
|
+
# @return ["variable", "fixed", "kind"] the duration kind of the layout
|
540
|
+
attribute :duration_kind
|
541
|
+
|
523
542
|
# @!attribute favorite
|
524
543
|
# @return [Boolean] whether the layout is a favorite for the current account
|
525
544
|
attribute :favorite
|
@@ -547,11 +566,25 @@ module LWS::DigitalSignage
|
|
547
566
|
# @return [Boolean] whether the layout has priority over others
|
548
567
|
attribute :priority
|
549
568
|
|
569
|
+
# @!attribute public
|
570
|
+
# @return [Boolean] whether the layout is public (i.e. shared with all
|
571
|
+
# companies)
|
572
|
+
attribute :public
|
573
|
+
|
574
|
+
# @!attribute rotation
|
575
|
+
# @return ["landscape", "portrait"] the rotation (orientation) of the
|
576
|
+
# layout
|
577
|
+
attribute :rotation
|
578
|
+
|
550
579
|
# @!attribute slides
|
551
580
|
# @return [Array<Slide>] the slides using the layout
|
552
581
|
has_many :slides, class_name: "LWS::DigitalSignage::Slide",
|
553
582
|
uri: "layouts/:layout_id/slides(/:id)"
|
554
583
|
|
584
|
+
# @!attribute thumbnail_url
|
585
|
+
# @return [String, nil] the URL of the thumbnail of the layout
|
586
|
+
attribute :thumbnail_url
|
587
|
+
|
555
588
|
# @!attribute trans
|
556
589
|
# @return ["cut", "fadein", "zoomin", "slidein"] the transition of the
|
557
590
|
# entire layout
|
@@ -801,9 +834,9 @@ module LWS::DigitalSignage
|
|
801
834
|
# @return [Integer] the ID of the configuration of the player
|
802
835
|
attribute :configuration_id
|
803
836
|
|
804
|
-
# @!attribute
|
805
|
-
# @return [
|
806
|
-
|
837
|
+
# @!attribute feedback
|
838
|
+
# @return [Hash{String=>String}] a mapping of player feedback key/values
|
839
|
+
attribute :feedback
|
807
840
|
|
808
841
|
# @!attribute [r] health_percentage
|
809
842
|
# @return [Fixnum] the health of the player (percentage)
|
@@ -834,13 +867,17 @@ module LWS::DigitalSignage
|
|
834
867
|
# @return [Integer] the ID of the model of the player
|
835
868
|
attribute :model_id
|
836
869
|
|
870
|
+
# @!attribute name
|
871
|
+
# @return [String] the name of the player
|
872
|
+
attribute :name
|
873
|
+
|
837
874
|
# @!attribute notifications
|
838
875
|
# @return [Array<Player::Notification>] the notifications for the player
|
839
876
|
has_many :notifications, class_name: "LWS::DigitalSignage::Player::Notification"
|
840
877
|
|
841
|
-
# @!attribute
|
878
|
+
# @!attribute operation_hours [r]
|
842
879
|
# @return [String, nil] the number of hours the player has been operational
|
843
|
-
attribute :
|
880
|
+
attribute :operation_hours
|
844
881
|
|
845
882
|
# @!attribute operational_since [r]
|
846
883
|
# @return [String, nil] the date/time when the player became operational
|
@@ -871,7 +908,7 @@ module LWS::DigitalSignage
|
|
871
908
|
attribute :release_channel_id
|
872
909
|
|
873
910
|
# @!attribute requests
|
874
|
-
# @return [Array<Player::
|
911
|
+
# @return [Array<Player::Request>] the requests for the player
|
875
912
|
has_many :requests, class_name: "LWS::DigitalSignage::Player::Request"
|
876
913
|
|
877
914
|
# @!attribute screenshots
|
@@ -890,6 +927,15 @@ module LWS::DigitalSignage
|
|
890
927
|
# @return ["unknown", "good", "warning", "bad"] the player status
|
891
928
|
attribute :status
|
892
929
|
|
930
|
+
# @!attribute status_reason [r]
|
931
|
+
# @return ["unknown", "hardware_failure", "outdated_os", "good", "connection_inactive_short",
|
932
|
+
# "connection_inactive_long"] the reason for the current player status
|
933
|
+
attribute :status_reason
|
934
|
+
|
935
|
+
# @!attribute status_updated_at [r]
|
936
|
+
# @return [String] the date/time the status was last updated
|
937
|
+
attribute :status_updated_at
|
938
|
+
|
893
939
|
# @!attribute tags
|
894
940
|
# @return [Array<Player::Tag>] the tags of the player
|
895
941
|
has_many :tags, class_name: "LWS::DigitalSignage::Player::Tag"
|
@@ -1040,75 +1086,6 @@ module LWS::DigitalSignage
|
|
1040
1086
|
attribute :value
|
1041
1087
|
end
|
1042
1088
|
|
1043
|
-
# = The player feedback class
|
1044
|
-
#
|
1045
|
-
# @note
|
1046
|
-
# This class is only used within the context of the {Player} class.
|
1047
|
-
class Player::Feedback < LWS::Generic::Model
|
1048
|
-
use_api LWS::DigitalSignage.api
|
1049
|
-
uri "players/:player_id/feedbacks(/:id)"
|
1050
|
-
|
1051
|
-
# @!attribute player
|
1052
|
-
# @return [Player] the player the feedback is originating from
|
1053
|
-
belongs_to :player, class_name: "LWS::DigitalSignage::Player"
|
1054
|
-
|
1055
|
-
# @!attribute player_id
|
1056
|
-
# @return [Integer] the ID of the player the feedback is originating from
|
1057
|
-
attribute :player_id
|
1058
|
-
|
1059
|
-
# @!attribute release
|
1060
|
-
# @return [Player::Os::Branch::Release] the player OS branch release the
|
1061
|
-
# feedback is related to
|
1062
|
-
# FIXME: Missing branch_id field in LWS
|
1063
|
-
belongs_to :release, class_name: "LWS::DigitalSignage::Player::Os::Branch::Release",
|
1064
|
-
uri: "player/os/branches/:branch_id/releases/:id"
|
1065
|
-
|
1066
|
-
# @!attribute release_id
|
1067
|
-
# @return [Integer] the ID of the player OS branch release the feedback
|
1068
|
-
# is related to
|
1069
|
-
|
1070
|
-
# @!attribute results
|
1071
|
-
# @return [Array<Player::Feedback::Result>] the results of the player feedback
|
1072
|
-
# FIXME: Chained associations don't work yet in Spyke (#89)
|
1073
|
-
has_many :results, class_name: "LWS::DigitalSignage::Player::Feedback::Result",
|
1074
|
-
uri: "players/:player_id/feedbacks/:feedback_id/results(/:id)"
|
1075
|
-
end
|
1076
|
-
|
1077
|
-
# = The player feedback result class
|
1078
|
-
#
|
1079
|
-
# @note
|
1080
|
-
# This class is only used within the context of the {Player::Feedback}
|
1081
|
-
# class.
|
1082
|
-
class Player::Feedback::Result < LWS::Generic::Model
|
1083
|
-
use_api LWS::DigitalSignage.api
|
1084
|
-
uri "players/:player_id/feedbacks/:feedback_id/results(/:id)"
|
1085
|
-
|
1086
|
-
# @!attribute feedback
|
1087
|
-
# @return [Player::Feedback] the player feedback the result is a part of
|
1088
|
-
belongs_to :feedback, class_name: "LWS::DigitalSignage::Player::Feedback",
|
1089
|
-
uri: "players/:player_id/feedbacks/:id"
|
1090
|
-
|
1091
|
-
# @!attribute feedback_id
|
1092
|
-
# @return [Player::Feedback] the ID of the player feedback the result is a part of
|
1093
|
-
attribute :feedback_id
|
1094
|
-
|
1095
|
-
# @!attribute key
|
1096
|
-
# @return [String] the key of the player feedback result
|
1097
|
-
attribute :key
|
1098
|
-
|
1099
|
-
# @!attribute player
|
1100
|
-
# @return [Player] the player the feedback result is for
|
1101
|
-
belongs_to :player, class_name: "LWS::DigitalSignage::Player"
|
1102
|
-
|
1103
|
-
# @!attribute player_id
|
1104
|
-
# @return [Integer] the ID of the player the feedback result is for
|
1105
|
-
attribute :player_id
|
1106
|
-
|
1107
|
-
# @!attribute value
|
1108
|
-
# @return [String] the value of the player feedback result
|
1109
|
-
attribute :value
|
1110
|
-
end
|
1111
|
-
|
1112
1089
|
# = The player log class
|
1113
1090
|
#
|
1114
1091
|
# @note
|
@@ -1632,20 +1609,6 @@ module LWS::DigitalSignage
|
|
1632
1609
|
# @return [String, nil] the optional argument for the player request
|
1633
1610
|
attribute :argument
|
1634
1611
|
|
1635
|
-
# @!attribute feedback
|
1636
|
-
# This field should be set once the action has been processed (see
|
1637
|
-
# {#processed}) and the action is +"send_feedback"+.
|
1638
|
-
#
|
1639
|
-
# @return [Player::Feedback, nil] the player feedback as a response to the
|
1640
|
-
# action request +"send_status"+
|
1641
|
-
belongs_to :feedback, class_name: "LWS::DigitalSignage::Player::Feedback",
|
1642
|
-
uri: "players/:player_id/feedbacks/:id"
|
1643
|
-
|
1644
|
-
# @!attribute feedback_id
|
1645
|
-
# @return [Integer, nil] the ID of the player feedback as a response to the
|
1646
|
-
# action request +"send_status"+
|
1647
|
-
attribute :feedback_id
|
1648
|
-
|
1649
1612
|
# @!attribute log
|
1650
1613
|
# This field should be set once the action has been processed (see
|
1651
1614
|
# {#processed}) and the action is +"send_logs"+.
|
@@ -1764,6 +1727,10 @@ module LWS::DigitalSignage
|
|
1764
1727
|
# scheduled on
|
1765
1728
|
has_many :channel_groups, class_name: "LWS::DigitalSignage::Channel::Group"
|
1766
1729
|
|
1730
|
+
# @!attribute comments
|
1731
|
+
# @return [String, nil] the comments/remarks for the slide
|
1732
|
+
attribute :comments
|
1733
|
+
|
1767
1734
|
# @!attribute company
|
1768
1735
|
# @return [LWS::Auth::Company] the company the slide belongs to
|
1769
1736
|
belongs_to :company, class_name: "LWS::Auth::Company"
|
@@ -1772,6 +1739,19 @@ module LWS::DigitalSignage
|
|
1772
1739
|
# @return [Integer] the ID of the company the slide belongs to
|
1773
1740
|
attribute :company_id
|
1774
1741
|
|
1742
|
+
# @!attribute duration
|
1743
|
+
# @return [Integer, nil] the duration of the slide (for fixed or content-bound durations
|
1744
|
+
# in the layout)
|
1745
|
+
attribute :duration
|
1746
|
+
|
1747
|
+
# @!attribute edit_account_ids
|
1748
|
+
# @return [Array<Integer>] the IDs of the accounts that can edit the slide
|
1749
|
+
attribute :edit_account_ids
|
1750
|
+
|
1751
|
+
# @!attribute editable_by_me
|
1752
|
+
# @return [Boolean] whether the authenticated user can edit the slide
|
1753
|
+
attribute :editable_by_me
|
1754
|
+
|
1775
1755
|
# @!attribute layout
|
1776
1756
|
# @return [LWS::Layout] the layout the slide uses
|
1777
1757
|
belongs_to :layout
|
@@ -1790,13 +1770,16 @@ module LWS::DigitalSignage
|
|
1790
1770
|
|
1791
1771
|
# @!attribute schedules
|
1792
1772
|
# @return [Array<Schedule>] the slide schedules that apply for the slide
|
1793
|
-
# FIXME: Missing endpoint in LWS
|
1794
1773
|
has_many :schedules, class_name: "LWS::DigitalSignage::Slide::Schedule"
|
1795
1774
|
|
1796
1775
|
# @!attribute status [r]
|
1797
1776
|
# @return ["initializing", "waiting_content", "available", "error"]
|
1798
1777
|
# the status of the slide
|
1799
1778
|
attribute :status
|
1779
|
+
|
1780
|
+
# @!attribute thumbnail_url
|
1781
|
+
# @return [String, nil] the URL of the thumbnail of the slide
|
1782
|
+
attribute :thumbnail_url
|
1800
1783
|
end
|
1801
1784
|
|
1802
1785
|
# = The slide schedule class
|
data/lib/lws/apps/generic.rb
CHANGED
@@ -79,8 +79,10 @@ module LWS::Generic
|
|
79
79
|
# Sets the Faraday API object used for this class. This will used by
|
80
80
|
# Spyke.
|
81
81
|
#
|
82
|
-
# @param api
|
83
|
-
#
|
82
|
+
# @param [Faraday::Connection] api A Faraday connection that makes
|
83
|
+
# requests to the API
|
84
|
+
# @return [Faraday::Connection] The Faraday connection that makes requests
|
85
|
+
# to the API
|
84
86
|
def self.use_api(api)
|
85
87
|
self.connection = api
|
86
88
|
self.include_root_in_json self.name.split("::").last.underscore.to_sym
|
@@ -150,8 +152,9 @@ module LWS::Generic
|
|
150
152
|
result
|
151
153
|
end
|
152
154
|
|
153
|
-
# Extracts a nested attribute
|
155
|
+
# Extracts a nested attribute value specified by the sequence of attribute names
|
154
156
|
# by calling dig at each step, returning +nil+ if any intermediate step is +nil+.
|
157
|
+
# @return [Object, nil] the digged up value or +nil+
|
155
158
|
def dig(*attrs)
|
156
159
|
attr = attrs.shift
|
157
160
|
value = send(attr)
|
@@ -161,6 +164,20 @@ module LWS::Generic
|
|
161
164
|
value.dig(*attrs)
|
162
165
|
end
|
163
166
|
|
167
|
+
# Returns a deep copy of the model.
|
168
|
+
# @return [Model] a deep copy of the model
|
169
|
+
def deep_dup
|
170
|
+
dup_obj = super
|
171
|
+
dup_obj.instance_eval do
|
172
|
+
@changed_attributes = @changed_attributes.deep_dup
|
173
|
+
@previously_changed = @previously_changed.deep_dup
|
174
|
+
@scope = @scope.deep_dup
|
175
|
+
@spyke_attributes = @spyke_attributes.deep_dup
|
176
|
+
@uri_template = @uri_template.deep_dup
|
177
|
+
end
|
178
|
+
dup_obj
|
179
|
+
end
|
180
|
+
|
164
181
|
end
|
165
182
|
|
166
183
|
# = The configuration class
|
@@ -180,9 +197,11 @@ module LWS::Generic
|
|
180
197
|
class Storage
|
181
198
|
# @!visibility private
|
182
199
|
def self.use_api(api)
|
183
|
-
|
184
|
-
config = LWS.config
|
200
|
+
config = LWS.config
|
185
201
|
|
202
|
+
# A connection to Active Storage (with JSON request/response, but without
|
203
|
+
# token authentication and caching).
|
204
|
+
@as_connection = Faraday.new(url: api.url_prefix) do |c|
|
186
205
|
# Request
|
187
206
|
c.request :json
|
188
207
|
|
@@ -197,6 +216,36 @@ module LWS::Generic
|
|
197
216
|
c.adapter Faraday.default_adapter
|
198
217
|
end
|
199
218
|
end
|
219
|
+
|
220
|
+
# A plain file connection to LWS (with token autnentication and caching but without
|
221
|
+
# JSON request/response).
|
222
|
+
@lws_connection = Faraday.new(url: api.url_prefix) do |c|
|
223
|
+
# Request
|
224
|
+
if config.caching_object
|
225
|
+
c.use FaradayMiddleware::Caching, config.caching_object
|
226
|
+
end
|
227
|
+
c.use LWS::Middleware::RequestHeaders, config.api_token
|
228
|
+
c.use config.api_token_middleware if config.api_token_middleware.present?
|
229
|
+
|
230
|
+
# Response
|
231
|
+
c.use FaradayMiddleware::FollowRedirects, limit: 3
|
232
|
+
c.use LWS::HTTPLogger, config.logger, config.http_debug_headers if config.http_debug
|
233
|
+
|
234
|
+
# Adapter
|
235
|
+
if config.http_persistent
|
236
|
+
c.adapter :net_http_persistent
|
237
|
+
else
|
238
|
+
c.adapter Faraday.default_adapter
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
# (see .upload)
|
244
|
+
# @deprecated
|
245
|
+
# To have a consistent upload/download naming counterpart, this
|
246
|
+
# method has been deprecated. Use {.upload} instead.
|
247
|
+
def self.create(file_or_io, filename, content_type = "application/octet-stream")
|
248
|
+
upload(file_or_io, filename, content_type)
|
200
249
|
end
|
201
250
|
|
202
251
|
# Uploads a file (or IO object) to the storage of the app module.
|
@@ -208,7 +257,7 @@ module LWS::Generic
|
|
208
257
|
# @param filename [String] the filename to use for the uploaded file/IO object
|
209
258
|
# @param content_type [String] the content type of the uploaded file/IO object
|
210
259
|
# @return [String, nil] the storage ID (if successful)
|
211
|
-
def self.
|
260
|
+
def self.upload(file_or_io, filename, content_type = "application/octet-stream")
|
212
261
|
return nil if file_or_io.closed?
|
213
262
|
|
214
263
|
data = file_or_io.read
|
@@ -217,7 +266,7 @@ module LWS::Generic
|
|
217
266
|
content_type: content_type,
|
218
267
|
byte_size: data.length,
|
219
268
|
checksum: checksum } }
|
220
|
-
res = @
|
269
|
+
res = @as_connection.post do |req|
|
221
270
|
req.url "rails/active_storage/direct_uploads"
|
222
271
|
req.headers["Accept"] = "application/json"
|
223
272
|
req.headers["Content-Type"] = "application/json"
|
@@ -226,7 +275,7 @@ module LWS::Generic
|
|
226
275
|
|
227
276
|
if res.success?
|
228
277
|
result = JSON.parse(res.body)
|
229
|
-
res = @
|
278
|
+
res = @as_connection.put do |req|
|
230
279
|
req.url result.dig("direct_upload", "url")
|
231
280
|
result.dig("direct_upload", "headers").each do |hdr, val|
|
232
281
|
req.headers[hdr] = val
|
@@ -240,6 +289,24 @@ module LWS::Generic
|
|
240
289
|
nil
|
241
290
|
end
|
242
291
|
end
|
243
|
-
end
|
244
292
|
|
293
|
+
# Downloads a file at the provided URL from the storage using the
|
294
|
+
# appropriate API tokens.
|
295
|
+
#
|
296
|
+
# This method can be used to download images/assets/etc. from LWS using
|
297
|
+
# URLs provided by attributes that end with +_url+.
|
298
|
+
# @param url [String] the URL to download the file from
|
299
|
+
# @return [String] the contents of the file
|
300
|
+
def self.download(url)
|
301
|
+
return nil if url.nil?
|
302
|
+
|
303
|
+
unless url.start_with? @lws_connection.url_prefix.to_s
|
304
|
+
raise ArgumentError,
|
305
|
+
"URL does not belong to this LWS app (endpoint: #{@lws_connection.url_prefix})"
|
306
|
+
end
|
307
|
+
|
308
|
+
res = @lws_connection.get(url)
|
309
|
+
res.body
|
310
|
+
end
|
311
|
+
end
|
245
312
|
end
|
data/lib/lws/apps/presence.rb
CHANGED
@@ -88,6 +88,46 @@ module LWS::Presence
|
|
88
88
|
attribute :uuid
|
89
89
|
end
|
90
90
|
|
91
|
+
# = The journal (entry) class
|
92
|
+
#
|
93
|
+
# @note
|
94
|
+
# This class is only used within the context of the {Location} class.
|
95
|
+
class Journal < LWS::Generic::Model
|
96
|
+
use_api LWS::Presence.api
|
97
|
+
|
98
|
+
# @!attribute check_in
|
99
|
+
# @return [String] the timestamp of the check-in of this journal (entry)
|
100
|
+
attribute :check_in
|
101
|
+
|
102
|
+
# @!attribute check_out
|
103
|
+
# @return [String, nil] the timestamp of the check out of this journal (entry)
|
104
|
+
attribute :check_out
|
105
|
+
|
106
|
+
# @!attribute company
|
107
|
+
# @return [LWS::Auth::Company] the company the journal (entry) belongs to
|
108
|
+
belongs_to :company, class_name: "LWS::Auth::Company"
|
109
|
+
|
110
|
+
# @!attribute company_id
|
111
|
+
# @return [Integer] the ID of the company the journal (entry) belongs to
|
112
|
+
attribute :company_id
|
113
|
+
|
114
|
+
# @!attribute location
|
115
|
+
# @return [Location] the location the journal (entry) belongs to
|
116
|
+
belongs_to :location
|
117
|
+
|
118
|
+
# @!attribute location_id
|
119
|
+
# @return [Integer] the ID of the location the journal (entry) belongs to
|
120
|
+
attribute :location_id
|
121
|
+
|
122
|
+
# @!attribute person
|
123
|
+
# @return [Person] the person the journal (entry) belongs to
|
124
|
+
belongs_to :person
|
125
|
+
|
126
|
+
# @!attribute person_id
|
127
|
+
# @return [Integer] the ID of the person the journal (entry) belongs to
|
128
|
+
attribute :person_id
|
129
|
+
end
|
130
|
+
|
91
131
|
# = The location class
|
92
132
|
class Location < LWS::Generic::Model
|
93
133
|
use_api LWS::Presence.api
|
@@ -133,6 +173,14 @@ module LWS::Presence
|
|
133
173
|
# the presence status to set people to when checking in
|
134
174
|
attribute :checkin_status
|
135
175
|
|
176
|
+
# @!attribute checkout_alter_status
|
177
|
+
# @return ["available", "unavailable", "maintenance_cleaning",
|
178
|
+
# "maintenance_technical", "permanent_available",
|
179
|
+
# "permanent_unavailable", "permanent_maintenance_cleaning",
|
180
|
+
# "permanent_maintenance_technical", nil] the status to set the
|
181
|
+
# location to when someone checks out
|
182
|
+
attribute :checkout_alter_status
|
183
|
+
|
136
184
|
# @!attribute checkout_location
|
137
185
|
# @return [Location, nil] the location to move people to when they
|
138
186
|
# are checked out
|
@@ -157,13 +205,28 @@ module LWS::Presence
|
|
157
205
|
# @return [Array<Integer>] the IDs of the underlying locations of the location
|
158
206
|
attribute :descendant_ids
|
159
207
|
|
208
|
+
# @!attribute image_storage_id
|
209
|
+
# @return [String, nil] the storage ID of the image of the location
|
210
|
+
attribute :image_storage_id
|
211
|
+
|
212
|
+
# @!attribute image_url
|
213
|
+
# @note
|
214
|
+
# To be able retrieve this, the token needs to be passed via +X-Token+
|
215
|
+
# in the HTTP request headers!
|
216
|
+
# @return [String, nil] the URL of the image of the location
|
217
|
+
attribute :image_url
|
218
|
+
|
219
|
+
# @!attribute journals
|
220
|
+
# @return [Array<Journal>] the journal (entries) associated with the location
|
221
|
+
has_many :journals, class: "LWS::Presence::Journal"
|
222
|
+
|
160
223
|
# @!attribute lat
|
161
224
|
# @return [Float] the latitude of the location
|
162
225
|
attribute :lat
|
163
226
|
|
164
227
|
# @!attribute logoff_time
|
165
|
-
#
|
166
|
-
#
|
228
|
+
# The format of the time is +HH:MM+ and should be interpreted in the time zone
|
229
|
+
# of the location (see also {#time_zone}).
|
167
230
|
# @return [String] the time everybody is automatically logged off
|
168
231
|
attribute :logoff_time
|
169
232
|
|
@@ -221,6 +284,13 @@ module LWS::Presence
|
|
221
284
|
# @return [Array<Reader>] the (RFID/code/ID/...) readers linked to this location
|
222
285
|
has_many :readers
|
223
286
|
|
287
|
+
# @!attribute status
|
288
|
+
# @return ["available", "unavailable", "maintenance_cleaning",
|
289
|
+
# "maintenance_technical", "permanent_available",
|
290
|
+
# "permanent_unavailable", "permanent_maintenance_cleaning",
|
291
|
+
# "permanent_maintenance_technical"] the status of the location
|
292
|
+
attribute :status
|
293
|
+
|
224
294
|
# @!attribute time_zone
|
225
295
|
# @return [String] the time zone of the location
|
226
296
|
attribute :time_zone
|
@@ -238,6 +308,17 @@ module LWS::Presence
|
|
238
308
|
use_api LWS::Presence.api
|
239
309
|
uri "locations/:location_id/maps(/:id)"
|
240
310
|
|
311
|
+
# @!attribute image_storage_id
|
312
|
+
# @return [String, nil] the storage ID of the image of the map
|
313
|
+
attribute :image_storage_id
|
314
|
+
|
315
|
+
# @!attribute image_url
|
316
|
+
# @note
|
317
|
+
# To be able retrieve this, the token needs to be passed via +X-Token+
|
318
|
+
# in the HTTP request headers!
|
319
|
+
# @return [String, nil] the URL of the image of the map
|
320
|
+
attribute :image_url
|
321
|
+
|
241
322
|
# @!attribute location
|
242
323
|
# @return [Location] the location the map belongs to
|
243
324
|
belongs_to :location
|
@@ -251,6 +332,9 @@ module LWS::Presence
|
|
251
332
|
attribute :name
|
252
333
|
|
253
334
|
# @!attribute picture_url
|
335
|
+
# @deprecated
|
336
|
+
# Unauthenticated retrieval of the picture will not longer be supported
|
337
|
+
# in upcoming releases of LWS. Use {#image_url} instead!
|
254
338
|
# @return [String, nil] the URL of the picture of the map
|
255
339
|
attribute :picture_url
|
256
340
|
|
@@ -359,6 +443,17 @@ module LWS::Presence
|
|
359
443
|
# @return [Array<Appointment>] the appointments involving the person
|
360
444
|
has_many :appointments
|
361
445
|
|
446
|
+
# @!attribute avatar_storage_id
|
447
|
+
# @return [String, nil] the storage ID of the avatar of the person
|
448
|
+
attribute :avatar_storage_id
|
449
|
+
|
450
|
+
# @!attribute avatar_url
|
451
|
+
# @note
|
452
|
+
# To be able retrieve this, the token needs to be passed via +X-Token+
|
453
|
+
# in the HTTP request headers!
|
454
|
+
# @return [String, nil] the URL of the avatar of the person
|
455
|
+
attribute :avatar_url
|
456
|
+
|
362
457
|
# @!attribute company
|
363
458
|
# @return [LWS::Auth::Company] the company the person belongs to
|
364
459
|
belongs_to :company, class_name: "LWS::Auth::Company"
|
@@ -422,6 +517,14 @@ module LWS::Presence
|
|
422
517
|
# @return [Integer] the ID of the location the person is located at
|
423
518
|
attribute :location_id
|
424
519
|
|
520
|
+
# @!attribute location_status_change_permissions
|
521
|
+
# @return [Array<"available", "unavailable", "maintenance_cleaning",
|
522
|
+
# "maintenance_technical", "permanent_available",
|
523
|
+
# "permanent_unavailable", "permanent_maintenance_cleaning",
|
524
|
+
# "permanent_maintenance_technical">] the location statuses the person
|
525
|
+
# will clear to available on check-in
|
526
|
+
attribute :location_status_change_permissions
|
527
|
+
|
425
528
|
# @!attribute long
|
426
529
|
# @return [Float, nil] the exact longitude of the person's location
|
427
530
|
attribute :long
|
@@ -457,6 +560,9 @@ module LWS::Presence
|
|
457
560
|
attribute :phone_mobile
|
458
561
|
|
459
562
|
# @!attribute picture_url
|
563
|
+
# @deprecated
|
564
|
+
# Unauthenticated retrieval of the picture will not longer be supported
|
565
|
+
# in upcoming releases of LWS. Use {#avatar_url} instead!
|
460
566
|
# @return [String, nil] the URL of the picture of the person
|
461
567
|
attribute :picture_url
|
462
568
|
|
@@ -512,4 +618,9 @@ module LWS::Presence
|
|
512
618
|
attribute :node
|
513
619
|
end
|
514
620
|
|
621
|
+
# (see Generic::Storage)
|
622
|
+
class Storage < LWS::Generic::Storage
|
623
|
+
use_api LWS::Presence.api
|
624
|
+
end
|
625
|
+
|
515
626
|
end
|
data/lib/lws/config.rb
CHANGED
@@ -107,11 +107,15 @@ module LWS
|
|
107
107
|
# http_debug: true
|
108
108
|
# json_debug: true
|
109
109
|
#
|
110
|
+
# @param config_file [String] the path to the config file to load
|
111
|
+
# @param force_environment [Symbol, nil] the environment to enforce (if
|
112
|
+
# any)
|
110
113
|
# @return [Boolean] whether the config file was used
|
111
|
-
def load_config_file(config_file)
|
114
|
+
def load_config_file(config_file, force_environment = nil)
|
112
115
|
return false unless File.exist? config_file
|
113
116
|
config_data = YAML.load_file(config_file)
|
114
|
-
environment =
|
117
|
+
environment = force_environment ||
|
118
|
+
ENV["LC_LWS_ENV"] ||
|
115
119
|
config_data.dig("default", "environment") ||
|
116
120
|
self.environment
|
117
121
|
self.environment = environment.to_sym
|
@@ -122,20 +126,26 @@ module LWS
|
|
122
126
|
raise "encountered an invalid config property \"#{key}\" " +
|
123
127
|
"in config file #{config_file}!"
|
124
128
|
end
|
129
|
+
configure(key, value)
|
130
|
+
end
|
131
|
+
true
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
125
135
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
h
|
132
|
-
end
|
133
|
-
end
|
134
|
-
else
|
135
|
-
self[key.to_sym] = value unless self[key.to_sym]
|
136
|
+
def configure(key, value)
|
137
|
+
case key
|
138
|
+
when "endpoints"
|
139
|
+
if self.endpoints.empty?
|
140
|
+
configure_endpoints(value)
|
136
141
|
end
|
142
|
+
else
|
143
|
+
self[key.to_sym] ||= value
|
137
144
|
end
|
138
|
-
|
145
|
+
end
|
146
|
+
|
147
|
+
def configure_endpoints(endpoints)
|
148
|
+
self.endpoints = endpoints.transform_keys(&:to_sym)
|
139
149
|
end
|
140
150
|
|
141
151
|
end
|
data/lib/lws/version.rb
CHANGED
@@ -16,7 +16,7 @@ class TestCorporateWebsiteArticle < MiniTest::Test
|
|
16
16
|
include LWS::CorporateWebsite
|
17
17
|
|
18
18
|
def setup
|
19
|
-
@page = Page.
|
19
|
+
@page = Page.find(1)
|
20
20
|
@article = @page.articles.first
|
21
21
|
end
|
22
22
|
|
@@ -38,7 +38,7 @@ class TestCorporateWebsiteOfficeTime < MiniTest::Test
|
|
38
38
|
include LWS::CorporateWebsite
|
39
39
|
|
40
40
|
def setup
|
41
|
-
@office_time = OfficeTime.
|
41
|
+
@office_time = OfficeTime.find(1)
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_valid
|
@@ -54,7 +54,7 @@ class TestCorporateWebsitePage < MiniTest::Test
|
|
54
54
|
include LWS::CorporateWebsite
|
55
55
|
|
56
56
|
def setup
|
57
|
-
@page = Page.
|
57
|
+
@page = Page.find(1)
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_valid
|
@@ -75,7 +75,7 @@ end
|
|
75
75
|
# include LWS::CorporateWebsite
|
76
76
|
#
|
77
77
|
# def setup
|
78
|
-
# @social_page = SocialPage.
|
78
|
+
# @social_page = SocialPage.find(1)
|
79
79
|
# end
|
80
80
|
#
|
81
81
|
# def test_valid
|
@@ -96,7 +96,7 @@ class TestCorporateWebsiteSocialPost < MiniTest::Test
|
|
96
96
|
include LWS::CorporateWebsite
|
97
97
|
|
98
98
|
def setup
|
99
|
-
@social_post = SocialPost.
|
99
|
+
@social_post = SocialPost.find(1)
|
100
100
|
end
|
101
101
|
|
102
102
|
def test_valid
|
@@ -261,6 +261,7 @@ class TestDigitalSignageLayout < MiniTest::Test
|
|
261
261
|
def test_valid_associations
|
262
262
|
# FIXME: Missing endpoint in LWS
|
263
263
|
#assert_instance_of(Layout::Category, @layout.categories.first)
|
264
|
+
assert_instance_of(LWS::Auth::Company, @layout.company_owner)
|
264
265
|
# FIXME: Missing parent_id field in LWS
|
265
266
|
#assert_instance_of(Layout, @layout.parent)
|
266
267
|
# FIXME: Missing endpoint in LWS
|
@@ -530,64 +531,6 @@ class TestDigitalSignagePlayerConfigurationSetting < MiniTest::Test
|
|
530
531
|
|
531
532
|
end
|
532
533
|
|
533
|
-
class TestDigitalSignagePlayerFeedback < MiniTest::Test
|
534
|
-
|
535
|
-
include LWS::DigitalSignage
|
536
|
-
|
537
|
-
def setup
|
538
|
-
@player = Player.find(1)
|
539
|
-
# Player feedbacks only exist as child objects of players
|
540
|
-
@player_feedback = @player.feedbacks.first
|
541
|
-
end
|
542
|
-
|
543
|
-
def test_valid
|
544
|
-
refute_nil(@player_feedback)
|
545
|
-
assert_instance_of(Player::Feedback, @player_feedback)
|
546
|
-
refute_nil(@player_feedback.id)
|
547
|
-
end
|
548
|
-
|
549
|
-
def test_valid_associations
|
550
|
-
assert_instance_of(Player, @player_feedback.player)
|
551
|
-
assert_equal(@player, @player_feedback.player)
|
552
|
-
# FIXME: Missing branch_id field in LWS
|
553
|
-
#assert_instance_of(Player::Os::Branch::Release, @player_feedback.release)
|
554
|
-
# FIXME: Chained associations don't work yet in Spyke (#89)
|
555
|
-
#assert_instance_of(Player::Feedback::Result, @player_feedback.results.first)
|
556
|
-
end
|
557
|
-
|
558
|
-
end
|
559
|
-
|
560
|
-
class TestDigitalSignagePlayerFeedbackResult < MiniTest::Test
|
561
|
-
|
562
|
-
include LWS::DigitalSignage
|
563
|
-
|
564
|
-
def setup
|
565
|
-
@player = Player.find(1)
|
566
|
-
# Player feedbacks only exist as decendant objects of players
|
567
|
-
@player_feedback = @player.feedbacks.all.first
|
568
|
-
# Player feedback results only exist as decendant objects of player
|
569
|
-
# feedbacks
|
570
|
-
# FIXME: Chained associations don't work yet in Spyke (#89)
|
571
|
-
#@player_feedback_result = @player_feedback.results.first
|
572
|
-
end
|
573
|
-
|
574
|
-
# FIXME: Chained associations don't work yet in Spyke (#89)
|
575
|
-
#def test_valid
|
576
|
-
# refute_nil(@player_feedback_result)
|
577
|
-
# assert_instance_of(Player::Feedback::Result, @player_feedback_result)
|
578
|
-
# refute_nil(@player_feedback_result.id)
|
579
|
-
#end
|
580
|
-
|
581
|
-
# FIXME: Chained associations don't work yet in Spyke (#89)
|
582
|
-
#def test_valid_associations
|
583
|
-
# assert_instance_of(Player, @player_feedback_result.player)
|
584
|
-
# assert_equal(@player, @player_feedback_result.player)
|
585
|
-
# assert_instance_of(Player::Feedback, @player_feedback_result.feedback)
|
586
|
-
# assert_equal(@player_feedback, @player_feedback_result.feedback)
|
587
|
-
#end
|
588
|
-
|
589
|
-
end
|
590
|
-
|
591
534
|
class TestDigitalSignagePlayerLog < MiniTest::Test
|
592
535
|
|
593
536
|
include LWS::DigitalSignage
|
@@ -930,9 +873,7 @@ class TestDigitalSignagePlayerRequest < MiniTest::Test
|
|
930
873
|
assert_equal(@player, @player_request.player)
|
931
874
|
# FIXME: Chained associations don't work yet in Spyke (#89)
|
932
875
|
#if @player_request.processed
|
933
|
-
# if @player_request.
|
934
|
-
# assert_instance_of(Player::Feedback, @player_request.feedback)
|
935
|
-
# elsif @player_request.log.present?
|
876
|
+
# if @player_request.log.present?
|
936
877
|
# assert_instance_of(Player::Log, @player_request.log)
|
937
878
|
# elsif @player_request.screenshot.present?
|
938
879
|
# assert_instance_of(Player::Screenshot, @player_request.screenshot)
|
@@ -1010,6 +951,7 @@ class TestDigitalSignageSlide < MiniTest::Test
|
|
1010
951
|
assert_instance_of(Channel::Group, @slide.channel_groups.first)
|
1011
952
|
assert_instance_of(LWS::Auth::Company, @slide.company)
|
1012
953
|
assert_instance_of(Layout, @slide.layout)
|
954
|
+
assert_instance_of(Slide::Schedule, @slide.schedules.first)
|
1013
955
|
end
|
1014
956
|
|
1015
957
|
end
|
@@ -1021,20 +963,17 @@ class TestDigitalSignageSlideSchedule < MiniTest::Test
|
|
1021
963
|
def setup
|
1022
964
|
@slide = Slide.find(1)
|
1023
965
|
# Slide schedules only exist as decendant objects of players
|
1024
|
-
# FIXME: Endpoint is missing in LWS
|
1025
966
|
@slide_schedule = @slide.schedules.first
|
1026
967
|
end
|
1027
968
|
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
#end
|
969
|
+
def test_valid
|
970
|
+
refute_nil(@slide_schedule)
|
971
|
+
assert_instance_of(Slide::Schedule, @slide_schedule)
|
972
|
+
refute_nil(@slide_schedule.id)
|
973
|
+
end
|
1034
974
|
|
1035
|
-
# FIXME: Endpoint is missing in LWS
|
1036
975
|
#def test_valid_associations
|
1037
|
-
# assert_instance_of(Slide, @
|
976
|
+
# assert_instance_of(Slide, @slide_schedule.slides.first)
|
1038
977
|
#end
|
1039
978
|
|
1040
979
|
end
|
data/test/generic_test.rb
CHANGED
@@ -17,7 +17,7 @@ class TestGenericModel < MiniTest::Test
|
|
17
17
|
include LWS::Auth
|
18
18
|
|
19
19
|
def setup
|
20
|
-
@configuration = Configuration.
|
20
|
+
@configuration = Configuration.find(1)
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_her_compatibility
|
@@ -106,6 +106,20 @@ class TestGenericModel < MiniTest::Test
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
+
def test_deep_dup
|
110
|
+
company = LWS::Auth::Company.find(1)
|
111
|
+
company_dup = company.deep_dup
|
112
|
+
|
113
|
+
# The object itself
|
114
|
+
refute_equal(company.object_id, company_dup.object_id)
|
115
|
+
# An object as attribute value
|
116
|
+
refute_equal(company.address.object_id, company_dup.address.object_id)
|
117
|
+
# A related object
|
118
|
+
refute_equal(company.contact_person.object_id, company_dup.contact_person.object_id)
|
119
|
+
# An item in array of related objects
|
120
|
+
refute_equal(company.accounts.first.object_id, company_dup.accounts.first.object_id)
|
121
|
+
end
|
122
|
+
|
109
123
|
end
|
110
124
|
|
111
125
|
class TestGenericConfiguration < MiniTest::Test
|
@@ -114,7 +128,7 @@ class TestGenericConfiguration < MiniTest::Test
|
|
114
128
|
include LWS::Auth
|
115
129
|
|
116
130
|
def setup
|
117
|
-
@configuration = Configuration.
|
131
|
+
@configuration = Configuration.find(1)
|
118
132
|
end
|
119
133
|
|
120
134
|
def test_valid
|
@@ -128,15 +142,37 @@ end
|
|
128
142
|
class TestGenericStorage < MiniTest::Test
|
129
143
|
|
130
144
|
# Generic class needs to be accessed under some kind of app
|
131
|
-
include LWS::
|
145
|
+
include LWS::Presence
|
132
146
|
|
133
147
|
def test_upload
|
134
148
|
data = StringIO.new("some file contents\n")
|
149
|
+
refute_nil(Storage.upload(data, "test.txt", "text/plain"))
|
150
|
+
|
151
|
+
# Test the deprecated method (for now)
|
135
152
|
refute_nil(Storage.create(data, "test.txt", "text/plain"))
|
136
153
|
|
137
154
|
# Also test using the default HTTP adapter.
|
138
155
|
reconfigure(http_persistent: false)
|
139
156
|
data = StringIO.new("some more file contents\n")
|
140
|
-
refute_nil(Storage.
|
157
|
+
refute_nil(Storage.upload(data, "test2.txt", "text/plain"))
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_download
|
161
|
+
location = Location.find(1)
|
162
|
+
refute_nil(location.image_url)
|
163
|
+
|
164
|
+
data = Storage.download(location.image_url)
|
165
|
+
assert(data.size > 0)
|
166
|
+
|
167
|
+
assert_nil(Storage.download(nil))
|
168
|
+
|
169
|
+
assert_raises(ArgumentError) do
|
170
|
+
Storage.download("https://doesnot.exist.tld/some/file")
|
171
|
+
end
|
172
|
+
|
173
|
+
# Also test using the default HTTP adapter.
|
174
|
+
reconfigure(http_persistent: false)
|
175
|
+
data = Storage.download(location.image_url)
|
176
|
+
assert(data.size > 0)
|
141
177
|
end
|
142
178
|
end
|
data/test/maps_test.rb
CHANGED
@@ -16,7 +16,7 @@ class TestMapsMap < MiniTest::Test
|
|
16
16
|
include LWS::Maps
|
17
17
|
|
18
18
|
def setup
|
19
|
-
@map = Map.
|
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.
|
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.
|
63
|
+
@source = Source.find(1)
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_valid_source
|
data/test/presence_test.rb
CHANGED
@@ -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.
|
191
|
+
@reader = Reader.find(1)
|
169
192
|
end
|
170
193
|
|
171
194
|
def test_valid
|
data/test/resource_test.rb
CHANGED
@@ -25,7 +25,7 @@ class TestResourceCollection < MiniTest::Test
|
|
25
25
|
include LWS::Resource
|
26
26
|
|
27
27
|
def setup
|
28
|
-
@collection = Collection.
|
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").
|
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.
|
73
|
+
@folder = Folder.find(1)
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_valid
|
data/test/setup_test.rb
CHANGED
@@ -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
|
data/test/test_helper.rb
CHANGED
@@ -23,7 +23,7 @@ SimpleCov.at_exit do
|
|
23
23
|
result.format!
|
24
24
|
simplecov_test_suites = ['minitest']
|
25
25
|
parallel_offset = ENV['PARALLEL_TEST_GROUPS'] ? ENV['PARALLEL_TEST_GROUPS'].to_i - 1 : 0
|
26
|
-
minimum_coverage =
|
26
|
+
minimum_coverage = 95
|
27
27
|
# Count the number of commas in the command name to figure out how many result groups were combined into this result
|
28
28
|
if result.command_name.scan(/,/).size + 1 >= simplecov_test_suites.size + (parallel_offset * 2) # two parallel suites
|
29
29
|
# We only want to enforce minimum coverage after all test suites finish
|
@@ -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
|
-
|
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
|
-
|
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|
|
data/test/ticket_test.rb
CHANGED
@@ -40,7 +40,7 @@ class TestTicketGroup < MiniTest::Test
|
|
40
40
|
include LWS::Ticket
|
41
41
|
|
42
42
|
def setup
|
43
|
-
@group = Group.
|
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.
|
91
|
+
@tag = Tag.find(1)
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_valid_tag
|
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: 7.
|
4
|
+
version: 7.1.3
|
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-03
|
11
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday_middleware
|
@@ -296,27 +296,27 @@ signing_key:
|
|
296
296
|
specification_version: 4
|
297
297
|
summary: LeftClick web services library for Ruby
|
298
298
|
test_files:
|
299
|
-
- test/
|
299
|
+
- test/presence_test.rb
|
300
300
|
- test/fixtures/permissions.yml
|
301
|
-
- test/
|
302
|
-
- test/
|
303
|
-
- test/
|
304
|
-
- test/
|
301
|
+
- test/fixtures/auth.yml
|
302
|
+
- test/corporate_website_test.rb
|
303
|
+
- test/logger_test.rb
|
304
|
+
- test/support/with_env.rb
|
305
305
|
- test/stubbing_test.rb
|
306
|
+
- test/ticket_test.rb
|
306
307
|
- test/digital_signage_test.rb
|
307
|
-
- test/
|
308
|
-
- test/
|
308
|
+
- test/caching_test.rb
|
309
|
+
- test/auth_test.rb
|
310
|
+
- test/maps_test.rb
|
311
|
+
- test/json_parser_test.rb
|
312
|
+
- test/resource_test.rb
|
313
|
+
- test/config/endpoints.yml
|
309
314
|
- test/config/switch_env.yml
|
310
315
|
- test/config/invalid.yml
|
311
|
-
- test/config/tokens.yml
|
312
316
|
- test/config/empty.yml
|
313
|
-
- test/config/
|
314
|
-
- test/
|
315
|
-
- test/
|
316
|
-
- test/
|
317
|
-
- test/support/with_env.rb
|
318
|
-
- test/caching_test.rb
|
319
|
-
- test/presence_test.rb
|
320
|
-
- test/corporate_website_test.rb
|
321
|
-
- test/resource_test.rb
|
317
|
+
- test/config/tokens.yml
|
318
|
+
- test/config/full.yml
|
319
|
+
- test/setup_test.rb
|
320
|
+
- test/api_token_middleware_test.rb
|
322
321
|
- test/generic_test.rb
|
322
|
+
- test/test_helper.rb
|