job_notifier 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +3 -1
- data/job_notifier.gemspec +1 -0
- data/lib/job_notifier/engine.rb +3 -1
- data/lib/job_notifier/logger.rb +10 -14
- data/lib/job_notifier/version.rb +1 -1
- data/lib/job_notifier.rb +1 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +35 -0
- data/spec/dummy/log/test.log +6404 -0
- data/spec/lib/job_notifier/adapters_spec.rb +4 -2
- data/spec/lib/job_notifier/logger_spec.rb +79 -0
- metadata +17 -3
- data/spec/dummy/tmp/pids/server.pid +0 -1
@@ -6,8 +6,10 @@ RSpec.describe JobNotifier::Adapters do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "#get_adapter_path" do
|
9
|
-
it
|
10
|
-
"
|
9
|
+
it do
|
10
|
+
expect(subject.get_adapter_path("notifier").to_s).to match(
|
11
|
+
"app/assets/javascripts/job_notifier/notifier.js")
|
12
|
+
end
|
11
13
|
|
12
14
|
it "raises error with invalid adapter" do
|
13
15
|
expect { subject.get_adapter_path("invalid") } .to raise_error(
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe JobNotifier::Logger do
|
4
|
+
describe "#call" do
|
5
|
+
let(:status) { 200 }
|
6
|
+
let(:result) do
|
7
|
+
[
|
8
|
+
[
|
9
|
+
{ "status" => "pending" },
|
10
|
+
{ "status" => "pending" },
|
11
|
+
{ "status" => "finished" },
|
12
|
+
{ "status" => "failed" }
|
13
|
+
].to_json.to_s
|
14
|
+
]
|
15
|
+
end
|
16
|
+
let(:response) { [status, nil, result] }
|
17
|
+
|
18
|
+
let(:env) { { "PATH_INFO" => "/job_notifier/XXX/jobs/pending.json" } }
|
19
|
+
let(:app) { double(:app, call: response) }
|
20
|
+
|
21
|
+
let(:logger) { described_class.new(app) }
|
22
|
+
|
23
|
+
before { allow(DateTime).to receive(:now).and_return("1984-06-04 10:00:00".to_datetime) }
|
24
|
+
|
25
|
+
RSpec.shared_examples "invalid candidate for logging" do
|
26
|
+
it "does not write log info" do
|
27
|
+
allow(logger).to receive(:log_jobs_info)
|
28
|
+
logger.call(env)
|
29
|
+
expect(logger).not_to have_received(:log_jobs_info)
|
30
|
+
end
|
31
|
+
|
32
|
+
it { expect(logger.call(env)).to eq(response) }
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec.shared_examples "invalid request result" do
|
36
|
+
it "calls logger with result" do
|
37
|
+
allow(logger).to receive(:log_jobs_info)
|
38
|
+
logger.call(env)
|
39
|
+
expect(logger).to have_received(:log_jobs_info).with(result)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "does not build log msg" do
|
43
|
+
allow(logger).to receive(:build_log_msg)
|
44
|
+
logger.call(env)
|
45
|
+
expect(logger).not_to have_received(:build_log_msg)
|
46
|
+
end
|
47
|
+
|
48
|
+
it { expect(logger.call(env)).to eq(response) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context "with other than 200 status" do
|
52
|
+
let(:status) { 500 }
|
53
|
+
it_behaves_like("invalid candidate for logging")
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with invalid path info" do
|
57
|
+
let(:env) { { "PATH_INFO" => "/invalid/path" } }
|
58
|
+
it_behaves_like("invalid candidate for logging")
|
59
|
+
end
|
60
|
+
|
61
|
+
context "with blank result" do
|
62
|
+
let(:result) { [""] }
|
63
|
+
it_behaves_like("invalid request result")
|
64
|
+
end
|
65
|
+
|
66
|
+
context "with empty array result" do
|
67
|
+
let(:result) { ["[]"] }
|
68
|
+
it_behaves_like("invalid request result")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "prints log" do
|
72
|
+
out = "\e[0;94;49m[1984-06-04 10:00:00] JOBS\e[0m \e[0;33;49mPending: 2\e[0m \
|
73
|
+
\e[0;32;49mFinished: 1\e[0m \e[0;31;49mFailed: 1\e[0m\n"
|
74
|
+
expect { logger.call(env) }.to output(out).to_stdout
|
75
|
+
end
|
76
|
+
|
77
|
+
it { expect(logger.call(env)).to eq(response) }
|
78
|
+
end
|
79
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: job_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Platanus
|
@@ -72,6 +72,20 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 0.7.7
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: silencer
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.0.0.rc3
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.0.0.rc3
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: pry
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -539,10 +553,10 @@ files:
|
|
539
553
|
- spec/dummy/tmp/cache/assets/sprockets/v3.0/zOXm0fB3RP5lEZn8K0XLe2Fb2FA_lBFW82FCmFjpvpY.cache
|
540
554
|
- spec/dummy/tmp/cache/assets/sprockets/v3.0/zQ/zQTqJeOz-Koa7PhvVTyhn-cid6B6Ws-h8MHTOrRpW70.cache
|
541
555
|
- spec/dummy/tmp/cache/assets/sprockets/v3.0/zyjOXS82e6TASMmjcGsoBMiZ3uxt7D8DLxVHPvajMDU.cache
|
542
|
-
- spec/dummy/tmp/pids/server.pid
|
543
556
|
- spec/factories/job_notifier_jobs.rb
|
544
557
|
- spec/lib/job_notifier/adapters_spec.rb
|
545
558
|
- spec/lib/job_notifier/identifier_spec.rb
|
559
|
+
- spec/lib/job_notifier/logger_spec.rb
|
546
560
|
- spec/lib/job_notifier/notifier_spec.rb
|
547
561
|
- spec/models/job_notifier/job_spec.rb
|
548
562
|
- spec/rails_helper.rb
|
@@ -939,10 +953,10 @@ test_files:
|
|
939
953
|
- spec/dummy/tmp/cache/assets/sprockets/v3.0/zOXm0fB3RP5lEZn8K0XLe2Fb2FA_lBFW82FCmFjpvpY.cache
|
940
954
|
- spec/dummy/tmp/cache/assets/sprockets/v3.0/zQ/zQTqJeOz-Koa7PhvVTyhn-cid6B6Ws-h8MHTOrRpW70.cache
|
941
955
|
- spec/dummy/tmp/cache/assets/sprockets/v3.0/zyjOXS82e6TASMmjcGsoBMiZ3uxt7D8DLxVHPvajMDU.cache
|
942
|
-
- spec/dummy/tmp/pids/server.pid
|
943
956
|
- spec/factories/job_notifier_jobs.rb
|
944
957
|
- spec/lib/job_notifier/adapters_spec.rb
|
945
958
|
- spec/lib/job_notifier/identifier_spec.rb
|
959
|
+
- spec/lib/job_notifier/logger_spec.rb
|
946
960
|
- spec/lib/job_notifier/notifier_spec.rb
|
947
961
|
- spec/models/job_notifier/job_spec.rb
|
948
962
|
- spec/rails_helper.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
52012
|