roqua-support 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/Gemfile.lock +11 -12
- data/lib/roqua/core_ext/activerecord/uniq_find_or_create.rb +4 -5
- data/lib/roqua/support/errors.rb +12 -6
- data/lib/roqua-support/version.rb +1 -1
- data/spec/roqua/core_ext/activerecord/uniq_find_or_create_spec.rb +2 -2
- data/spec/roqua/support/errors_spec.rb +14 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b4f2e07189d3ee1b5b4c0e6472bd3c1b4ba2c6a
|
4
|
+
data.tar.gz: 3ae9698e6c4b77a16e7ff1226cb9269e3d3f428c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ab8c7979cb7a686033f05b6a0a9e64e028a94a59a6a6186a5621826e91f044dcedb0075dfe337b38c32eb623a6f45d63ff64c0b38e52bfb65bbfded5b518281
|
7
|
+
data.tar.gz: 86c8129d450c4e37237488eeef12ffc1766813b8d3b0d78762b2ec4531aec0c83cbaeb9cd4db439edaddd47cc8bd2dab90f75758797d275c050b2fddc02284e0
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
roqua-support (0.1.
|
4
|
+
roqua-support (0.1.7)
|
5
5
|
activesupport (>= 3.2, < 5.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (4.0
|
11
|
-
i18n (~> 0.6, >= 0.6.
|
12
|
-
|
13
|
-
|
10
|
+
activesupport (4.1.0)
|
11
|
+
i18n (~> 0.6, >= 0.6.9)
|
12
|
+
json (~> 1.7, >= 1.7.7)
|
13
|
+
minitest (~> 5.1)
|
14
14
|
thread_safe (~> 0.1)
|
15
|
-
tzinfo (~>
|
16
|
-
atomic (1.1.15)
|
15
|
+
tzinfo (~> 1.1)
|
17
16
|
celluloid (0.15.2)
|
18
17
|
timers (~> 1.1.0)
|
19
18
|
celluloid-io (0.15.0)
|
@@ -36,6 +35,7 @@ GEM
|
|
36
35
|
guard (~> 2.1)
|
37
36
|
rspec (>= 2.14, < 4.0)
|
38
37
|
i18n (0.6.9)
|
38
|
+
json (1.8.1)
|
39
39
|
listen (2.5.0)
|
40
40
|
celluloid (>= 0.15.2)
|
41
41
|
celluloid-io (>= 0.15.0)
|
@@ -43,8 +43,7 @@ GEM
|
|
43
43
|
rb-inotify (>= 0.9)
|
44
44
|
lumberjack (1.0.4)
|
45
45
|
method_source (0.8.2)
|
46
|
-
minitest (
|
47
|
-
multi_json (1.9.0)
|
46
|
+
minitest (5.3.3)
|
48
47
|
nio4r (1.0.0)
|
49
48
|
pry (0.9.12.6)
|
50
49
|
coderay (~> 1.0)
|
@@ -65,10 +64,10 @@ GEM
|
|
65
64
|
ruby-progressbar (1.4.1)
|
66
65
|
slop (3.4.7)
|
67
66
|
thor (0.18.1)
|
68
|
-
thread_safe (0.
|
69
|
-
atomic (>= 1.1.7, < 2)
|
67
|
+
thread_safe (0.3.3)
|
70
68
|
timers (1.1.0)
|
71
|
-
tzinfo (
|
69
|
+
tzinfo (1.1.0)
|
70
|
+
thread_safe (~> 0.1)
|
72
71
|
|
73
72
|
PLATFORMS
|
74
73
|
ruby
|
@@ -8,10 +8,9 @@ module ActiveRecord
|
|
8
8
|
# raised. When no record can be found, because for instance validations fail on create, the created object
|
9
9
|
# containing the validation errors is returned instead.
|
10
10
|
def self.uniq_find_or_create_by(attributes, &block)
|
11
|
-
|
11
|
+
find_or_create_by(attributes, &block)
|
12
12
|
rescue ActiveRecord::RecordNotUnique => exception
|
13
|
-
|
14
|
-
return find_by(attributes) || record || raise(exception)
|
13
|
+
find_by(attributes) || raise(exception)
|
15
14
|
end
|
16
15
|
|
17
16
|
# Use this method if you want an exception to be raised when creating a new record fails due to some validation
|
@@ -19,9 +18,9 @@ module ActiveRecord
|
|
19
18
|
def self.uniq_find_or_create_by!(attributes, &block)
|
20
19
|
find_or_create_by!(attributes, &block)
|
21
20
|
rescue ActiveRecord::RecordNotUnique => exception
|
21
|
+
find_by(attributes) || raise(exception)
|
22
22
|
rescue ActiveRecord::RecordInvalid => exception
|
23
|
-
|
24
|
-
return find_by(attributes) || raise(exception)
|
23
|
+
find_by(attributes) || raise(exception)
|
25
24
|
end
|
26
25
|
end
|
27
26
|
end
|
data/lib/roqua/support/errors.rb
CHANGED
@@ -35,14 +35,20 @@ module Roqua
|
|
35
35
|
# Appsignal.send_exception(exception, parameters: parameters)
|
36
36
|
|
37
37
|
if Appsignal.active?
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
# Hackety hack around stateful mess of Appsignal gem
|
39
|
+
if Appsignal::Transaction.current
|
40
|
+
Appsignal::Transaction.current.set_tags(parameters)
|
41
|
+
Appsignal::Transaction.current.add_exception(exception)
|
42
|
+
else
|
43
|
+
transaction = Appsignal::Transaction.create(SecureRandom.uuid, ENV.to_hash)
|
44
|
+
transaction.set_tags(parameters)
|
45
|
+
transaction.add_exception(exception)
|
46
|
+
transaction.complete!
|
47
|
+
Appsignal.agent.send_queue
|
48
|
+
end
|
43
49
|
end
|
44
50
|
end
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
48
|
-
end
|
54
|
+
end
|
@@ -25,7 +25,7 @@ describe ActiveRecord::Base do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'returns a preexisting or created record by querying it' do
|
28
|
-
allow(ActiveRecord::Base).to receive(:
|
28
|
+
allow(ActiveRecord::Base).to receive(:find_or_create_by).with(attributes).and_return record
|
29
29
|
expect(ActiveRecord::Base.uniq_find_or_create_by attributes, &block).to eq(record)
|
30
30
|
end
|
31
31
|
|
@@ -59,7 +59,7 @@ describe ActiveRecord::Base do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'returns a preexisting or created record by querying it' do
|
62
|
-
allow(ActiveRecord::Base).to receive(:
|
62
|
+
allow(ActiveRecord::Base).to receive(:find_or_create_by!).with(attributes).and_return record
|
63
63
|
expect(ActiveRecord::Base.uniq_find_or_create_by! attributes, &block).to eq(record)
|
64
64
|
end
|
65
65
|
|
@@ -34,11 +34,11 @@ describe 'Error reporting' do
|
|
34
34
|
let(:agent) { double("agent") }
|
35
35
|
let(:transaction) { double("transaction") }
|
36
36
|
|
37
|
-
it 'sends notifications to appsignal' do
|
37
|
+
it 'sends notifications to appsignal when there is no current exception' do
|
38
38
|
stub_const("Appsignal", Module.new)
|
39
39
|
Appsignal.stub(active?: true)
|
40
40
|
Appsignal.stub(is_ignored_exception?: false, agent: agent)
|
41
|
-
stub_const("Appsignal::Transaction", double("Transaction", create: transaction))
|
41
|
+
stub_const("Appsignal::Transaction", double("Transaction", create: transaction, current: nil))
|
42
42
|
|
43
43
|
transaction.should_receive(:set_tags).with({})
|
44
44
|
transaction.should_receive(:add_exception).with(exception)
|
@@ -46,6 +46,17 @@ describe 'Error reporting' do
|
|
46
46
|
agent.should_receive(:send_queue)
|
47
47
|
Roqua::Support::Errors.report exception
|
48
48
|
end
|
49
|
+
|
50
|
+
it 'sends notifications to appsignal when there already is a current exception' do
|
51
|
+
stub_const("Appsignal", Module.new)
|
52
|
+
Appsignal.stub(active?: true)
|
53
|
+
Appsignal.stub(is_ignored_exception?: false, agent: agent)
|
54
|
+
stub_const("Appsignal::Transaction", double("Transaction", current: transaction))
|
55
|
+
|
56
|
+
transaction.should_receive(:set_tags).with({})
|
57
|
+
transaction.should_receive(:add_exception).with(exception)
|
58
|
+
Roqua::Support::Errors.report exception
|
59
|
+
end
|
49
60
|
end
|
50
61
|
|
51
62
|
it 'supports default extra params' do
|
@@ -57,4 +68,4 @@ describe 'Error reporting' do
|
|
57
68
|
parameters: {organization: 'some_org'})
|
58
69
|
Roqua::Support::Errors.report exception
|
59
70
|
end
|
60
|
-
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roqua-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.2.
|
140
|
+
rubygems_version: 2.2.2
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Helper objects and proxies used by a lot of RoQua applications
|