panda_pal 4.1.0.beta2 → 4.1.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/panda_pal/organization/settings_validation.rb +3 -7
- data/app/models/panda_pal/organization/task_scheduling.rb +10 -2
- data/lib/panda_pal/version.rb +1 -1
- data/spec/models/panda_pal/organization/task_scheduling_spec.rb +10 -0
- data/spec/spec_helper.rb +0 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef5b128c1f14031f45d4955e56094db8cab358ba
|
4
|
+
data.tar.gz: 0e55cffec0dc1dd61ce847d018f1140a047549ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db77dbe724b48bad8a1439e6296c48f1063cb90b22c9bf22a96f7e351cd5c6cbe186b1abe847983e35f3417bba4f1d4d9ce849f0628e158873a4db46d515b20f
|
7
|
+
data.tar.gz: a9257806e5ad3c1d24b5faf0b0ca030ed7819b2ddd4aa3f8c20f80da103a1f95fb08a0bda9fe714b4cda4da2b678c46ff2ed4a176e730e7627fc4ad2f4e2dc13
|
@@ -40,10 +40,8 @@ module PandaPal
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def validate_settings
|
43
|
-
|
44
|
-
|
45
|
-
errors[:settings] << err
|
46
|
-
end
|
43
|
+
validate_settings_level(settings || {}, settings_structure).each do |err|
|
44
|
+
errors[:settings] << err
|
47
45
|
end
|
48
46
|
end
|
49
47
|
|
@@ -76,9 +74,7 @@ module PandaPal
|
|
76
74
|
resolved_module = split_val[0].constantize
|
77
75
|
proc_result = resolved_module.send(split_val[1].to_sym, settings, spec, path: path, errors: val_errors)
|
78
76
|
elsif spec[:validate].is_a?(Proc)
|
79
|
-
proc_result =
|
80
|
-
spec[:validate].call(settings, spec, path: path, errors: val_errors)
|
81
|
-
end
|
77
|
+
proc_result = instance_exec(settings, spec, path: path, errors: val_errors, &spec[:validate])
|
82
78
|
end
|
83
79
|
val_errors << proc_result unless val_errors.present? || proc_result == val_errors
|
84
80
|
val_errors = val_errors.flatten.uniq.compact.map do |ve|
|
@@ -24,6 +24,14 @@ module PandaPal
|
|
24
24
|
super.tap do |struc|
|
25
25
|
struc[:properties] ||= {}
|
26
26
|
|
27
|
+
struc[:properties][:timezone] ||= {
|
28
|
+
type: 'String',
|
29
|
+
required: false,
|
30
|
+
validate: ->(timezone, *args) {
|
31
|
+
ActiveSupport::TimeZone[timezone].present? ? nil : "<path> Invalid Timezone '#{timezone}'"
|
32
|
+
},
|
33
|
+
}
|
34
|
+
|
27
35
|
struc[:properties][:task_schedules] = {
|
28
36
|
type: 'Hash',
|
29
37
|
required: false,
|
@@ -116,7 +124,7 @@ module PandaPal
|
|
116
124
|
|
117
125
|
return nil unless cron_time.present?
|
118
126
|
|
119
|
-
cron_time =
|
127
|
+
cron_time = instance_exec(&cron_time) if cron_time.is_a?(Proc)
|
120
128
|
if !Rufus::Scheduler.parse(cron_time).zone.present? && settings && settings[:timezone]
|
121
129
|
cron_time += " #{settings[:timezone]}"
|
122
130
|
end
|
@@ -134,7 +142,7 @@ module PandaPal
|
|
134
142
|
|
135
143
|
Apartment::Tenant.switch(org.name) do
|
136
144
|
if worker.is_a?(Proc)
|
137
|
-
org.
|
145
|
+
org.instance_exec(&worker)
|
138
146
|
elsif worker.is_a?(Symbol)
|
139
147
|
org.send(worker)
|
140
148
|
elsif worker.is_a?(String)
|
data/lib/panda_pal/version.rb
CHANGED
@@ -101,6 +101,16 @@ module PandaPal
|
|
101
101
|
organization.settings = {}
|
102
102
|
end
|
103
103
|
|
104
|
+
it 'passes a valid timezone' do
|
105
|
+
organization.settings[:timezone] = 'America/Denver'
|
106
|
+
expect(organization).to be_valid
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'fails an invalid timezone' do
|
110
|
+
organization.settings[:timezone] = 'Timezone/Blorg'
|
111
|
+
expect(organization).not_to be_valid
|
112
|
+
end
|
113
|
+
|
104
114
|
it 'allows [:task_schedules] entry to be missing' do
|
105
115
|
expect(organization).to be_valid
|
106
116
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -44,10 +44,6 @@ RSpec.configure do |config|
|
|
44
44
|
title: 'Test App',
|
45
45
|
settings_structure: {}
|
46
46
|
}
|
47
|
-
|
48
|
-
allow_any_instance_of(PandaPal::Organization).to receive(:switch_tenant) do |inst, &block|
|
49
|
-
block.call if block.present?
|
50
|
-
end
|
51
47
|
end
|
52
48
|
|
53
49
|
# The settings below are suggested to provide a good initial experience
|