triggerable 0.1.3 → 0.1.4

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: 50059bb341314ac2546438f420f9162ec1661715
4
- data.tar.gz: 3d523b78004b5820f2a27a08e5736c2efb49abfb
3
+ metadata.gz: 9689f441a8bf248c604c1a93480e52ae104c3770
4
+ data.tar.gz: b4642f6342c5e5c30b1fac31b707ead0162c2b41
5
5
  SHA512:
6
- metadata.gz: ed94209ac03b2fb05b95c4a11e087493c6017c6f015bf3a3e6013516c8c273e453d0ff1250287fc8da95bf4a52347720095e44be15d716e587484fd263b5b76e
7
- data.tar.gz: 408aca735a06cdd505ab0280d175b815586245d46df7e4fe6033042fbb3e37bcbc022ba81e6e0b88e5941cfe9fdebf7de900fe47c2b355f07a666924a8cafafc
6
+ metadata.gz: a1e76b55c3810ab112eaf7a2148227f0525333608c8c7064c827bd650b4fdf87db4bfd763c1206beded0d19f8b3b85cf80523cbe71eef3cf86f36066d6ddc167
7
+ data.tar.gz: cf4d50158a00bc4f9291b3d03fa19d44b7818176516ff010d19533b6b203517ed67c00f38a9c45aea478ca65661013b800a48749f05425b6da51b3e95c93a300
@@ -14,14 +14,20 @@ module Conditions
14
14
  end
15
15
 
16
16
  private
17
- def condition
18
- return super if @math_condition.blank?
19
17
 
20
- case @math_condition
21
- when :greater_than
22
- LessThanOrEqualTo.new(@field, from)
23
- when :less_than
24
- GreaterThanOrEqualTo.new(@field, from)
18
+ def condition
19
+ if @math_condition.blank?
20
+ And.new [
21
+ GreaterThan.new(@field, from),
22
+ LessThanOrEqualTo.new(@field, to)
23
+ ]
24
+ else
25
+ case @math_condition
26
+ when :greater_than
27
+ LessThanOrEqualTo.new(@field, from)
28
+ when :less_than
29
+ GreaterThanOrEqualTo.new(@field, from)
30
+ end
25
31
  end
26
32
  end
27
33
  end
@@ -22,13 +22,18 @@ module Conditions
22
22
 
23
23
  private
24
24
  def condition
25
- return super if @math_condition.blank?
26
-
27
- case @math_condition
28
- when :greater_than
29
- And.new([GreaterThanOrEqualTo.new(@field, from), LessThan.new(@field, to)])
30
- when :less_than
31
- GreaterThanOrEqualTo.new(@field, from)
25
+ if @math_condition.blank?
26
+ And.new [
27
+ GreaterThanOrEqualTo.new(@field, from),
28
+ LessThan.new(@field, to)
29
+ ]
30
+ else
31
+ case @math_condition
32
+ when :greater_than
33
+ And.new([GreaterThanOrEqualTo.new(@field, from), LessThan.new(@field, to)])
34
+ when :less_than
35
+ GreaterThanOrEqualTo.new(@field, from)
36
+ end
32
37
  end
33
38
  end
34
39
  end
@@ -22,12 +22,5 @@ module Conditions
22
22
  i = Engine.interval
23
23
  Time.at((Time.now.to_i / i) * i).utc
24
24
  end
25
-
26
- def condition
27
- And.new [
28
- GreaterThanOrEqualTo.new(@field, from),
29
- LessThan.new(@field, to)
30
- ]
31
- end
32
25
  end
33
26
  end
@@ -4,7 +4,7 @@ module Rules
4
4
  table = Arel::Table.new(model.table_name)
5
5
  scope = @condition.scope(table)
6
6
  query = table.where(scope).project(Arel.sql('id')).to_sql
7
- ids = ParentModel.connection.execute(query).map { |r| r['id'] }
7
+ ids = ActiveRecord::Base.connection.execute(query).map { |r| r['id'] }
8
8
  models = model.where(id: ids)
9
9
 
10
10
  models.each {|object| actions.each {|a| a.run_for!(object, name)} }
@@ -1,3 +1,3 @@
1
1
  module Triggerable
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -22,7 +22,7 @@ describe 'Automations' do
22
22
  Engine.run_automations(1.hour)
23
23
  expect(TestTask.count).to eq(1)
24
24
 
25
- constantize_time_now Time.utc 2012, 9, 2, 13, 00
25
+ constantize_time_now Time.utc 2012, 9, 2, 12, 00
26
26
  Engine.run_automations(1.hour)
27
27
 
28
28
  expect(TestTask.count).to eq(2)
@@ -52,7 +52,7 @@ describe 'Automations' do
52
52
  end
53
53
 
54
54
  it 'after 30 mins with 30 mins interval' do
55
- constantize_time_now Time.utc 2012, 9, 1, 11, 55
55
+ constantize_time_now Time.utc 2012, 9, 1, 12, 00
56
56
 
57
57
  TestTask.automation if: {and: [{updated_at: {after: 30.minutes}}, {status: {is: :solved}}, {kind: {is: :service}}]} do
58
58
  TestTask.create kind: 'follow up'
@@ -63,11 +63,11 @@ describe 'Automations' do
63
63
  task.update_attributes status: 'solved', kind: 'service'
64
64
  expect(TestTask.count).to eq(1)
65
65
 
66
- constantize_time_now Time.utc 2012, 9, 1, 12, 12
66
+ constantize_time_now Time.utc 2012, 9, 1, 12, 29
67
67
  Engine.run_automations(30.minutes)
68
68
  expect(TestTask.count).to eq(1)
69
69
 
70
- constantize_time_now Time.utc 2012, 9, 1, 12, 50
70
+ constantize_time_now Time.utc 2012, 9, 1, 12, 30
71
71
  Engine.run_automations(30.minutes)
72
72
 
73
73
  expect(TestTask.count).to eq(2)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: triggerable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev