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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c6ac3694136d009439988eff1703cd4df593166
4
- data.tar.gz: 0d41152d271eb99d7d248062a4f3500c8c146af1
3
+ metadata.gz: ef5b128c1f14031f45d4955e56094db8cab358ba
4
+ data.tar.gz: 0e55cffec0dc1dd61ce847d018f1140a047549ab
5
5
  SHA512:
6
- metadata.gz: b253820d23c08f25c61de72d420da969647e6c2cda98d3957bfd076c7e26b1752d383ea7c3d38018945eadb4b36fb880ccd2f0e5fdf5d0e38ce808aa8e3cf23f
7
- data.tar.gz: b9bae0c7b68314c457beeefc7f78d7f97fc6810be4aa94eb826779e9856c62b8ec9f80eb5fae43edb3870256773e2e5a30c3e56e7e29cab981ac0246cd28544a
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
- switch_tenant do
44
- validate_settings_level(settings || {}, settings_structure).each do |err|
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 = instance_eval do
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 = instance_eval(&cron_time) if cron_time.is_a?(Proc)
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.instance_eval(&worker)
145
+ org.instance_exec(&worker)
138
146
  elsif worker.is_a?(Symbol)
139
147
  org.send(worker)
140
148
  elsif worker.is_a?(String)
@@ -1,3 +1,3 @@
1
1
  module PandaPal
2
- VERSION = "4.1.0.beta2"
2
+ VERSION = "4.1.0.beta3"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_pal
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0.beta2
4
+ version: 4.1.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure ProServe