forest_liana 8.0.0.beta.2 → 8.0.0.beta.3

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
  SHA256:
3
- metadata.gz: 8c3bc9feb8975c2d4bb725c5badda68b4d880fcc3a2553cc2d1d6164f5e56366
4
- data.tar.gz: b1f6e70a0723450674b53944f933036fea21b4a9b6cceab806cf32cd7654896a
3
+ metadata.gz: 82036a005a4c2e31b6e1e48c7f9d5befacb5b72ba71046bd5bcfa83d43c19797
4
+ data.tar.gz: c825c64871dd4737961a589c3869c07126ddf8023265822cb73a2019aa82ed2e
5
5
  SHA512:
6
- metadata.gz: 42a2ae2c6800ea8cf501ee3896554852cd677003d2aea5353fbc2d74d5dee34ee55d02079f8a9a31949af19d7a6ecc8c97e8be3a15a9844aa2ae11ff2fb75e73
7
- data.tar.gz: 2a97e185ccde89910027740ea833a8e3373f4cb2466a16c2023554534be4ddc3c2419d40015be0edbecb6283a304d4ef4b80472fcea98b99649a122b28fb9c2e
6
+ metadata.gz: c519f23a7c267b77cd83a42859e9aac9996955d2ec918c1d562c5d3ceda2c15638840fae765b2241b12a2f5dba38be8de898923879cd2b8c82902a77c583192c
7
+ data.tar.gz: f3e06eabdee80eab3b8991c355a1af15e1601d2e8ba35adb7160f9d367958f7473f236cbb011f0907be5073cc111efc17138b67c88c727827def72ab8261d0c1
@@ -37,6 +37,8 @@ module ForestLiana
37
37
  elsif @smart_action['approvalRequired'].include?(@user['roleId'])
38
38
  if @smart_action['approvalRequiredConditions'].empty? || match_conditions('approvalRequiredConditions')
39
39
  raise ForestLiana::Ability::Exceptions::RequireApproval.new(@smart_action['userApprovalEnabled'])
40
+ else
41
+ return true if @smart_action['triggerConditions'].empty? || match_conditions('triggerConditions')
40
42
  end
41
43
  end
42
44
 
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "8.0.0.beta.2"
2
+ VERSION = "8.0.0.beta.3"
3
3
  end
@@ -205,9 +205,67 @@ module ForestLiana
205
205
  expect{smart_action_checker.can_execute?}.to raise_error(ForestLiana::Ability::Exceptions::TriggerForbidden)
206
206
  end
207
207
 
208
- it 'should raise error when triggerConditions not match' do
208
+ it 'should trigger action when approvalRequiredCondition not match but with triggerConditions matched' do
209
+ parameters = ActionController::Parameters.new(params).permit!
210
+ action['approvalRequired'] = [1]
211
+ action['triggerEnabled'] = [1]
212
+ action['triggerConditions'] = [
213
+ { 'filter' =>
214
+ { 'aggregator' => 'and',
215
+ 'conditions' =>
216
+ [
217
+ {
218
+ 'field' => 'name',
219
+ 'value' => 'foo',
220
+ 'source' => 'data',
221
+ 'operator' => 'equal'
222
+ }
223
+ ]
224
+ },
225
+ 'roleId' => 1
226
+ }
227
+ ]
228
+ action['approvalRequiredConditions'] = [
229
+ { 'filter' =>
230
+ { 'aggregator' => 'and',
231
+ 'conditions' =>
232
+ [
233
+ {
234
+ 'field' => 'name',
235
+ 'value' => 'fake island',
236
+ 'source' => 'data',
237
+ 'operator' => 'equal'
238
+ }
239
+ ]
240
+ },
241
+ 'roleId' => 1
242
+ }
243
+ ]
244
+ smart_action_checker = ForestLiana::Ability::Permission::SmartActionChecker.new(parameters, Island, action, user)
245
+
246
+ expect(smart_action_checker.can_execute?).to equal true
247
+ end
248
+
249
+ it 'should raise error when approvalRequiredConditions and triggerConditions not match' do
209
250
  parameters = ActionController::Parameters.new(params).permit!
210
251
  action['approvalRequired'] = [1]
252
+ action['triggerEnabled'] = [1]
253
+ action['triggerConditions'] = [
254
+ { 'filter' =>
255
+ { 'aggregator' => 'and',
256
+ 'conditions' =>
257
+ [
258
+ {
259
+ 'field' => 'name',
260
+ 'value' => 'fake island',
261
+ 'source' => 'data',
262
+ 'operator' => 'equal'
263
+ }
264
+ ]
265
+ },
266
+ 'roleId' => 1
267
+ }
268
+ ]
211
269
  action['approvalRequiredConditions'] = [
212
270
  { 'filter' =>
213
271
  { 'aggregator' => 'and',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0.beta.2
4
+ version: 8.0.0.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-21 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails