rrrspec-web 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rrrspec/web.rb +1 -0
- data/lib/rrrspec/web/api.rb +0 -50
- data/lib/rrrspec/web/version.rb +1 -1
- data/spec/rrrspec/web/api_spec.rb +2 -65
- data/spec/spec_helper.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74ee5aa013465a0f3fccc8043aeb8f43370bc354
|
4
|
+
data.tar.gz: 3a0fbc05bf9244d8033a6ad2430bf75c61f6276c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 645daaa283bcbcdbe3bebdaeb7e3d910f67419c2d12c32dcc736480dc53f7abdf8716bf75bedfaf4319b48b1f6186444d3e41f1d61648136e2edb0cfea2bbcbb
|
7
|
+
data.tar.gz: 40fb536e6e66ea5ca127015add099471f4b25128e86551e736bd3d2868fa13be4dc3eaa5e4d84c767124384488fffa2843179f15b03e0ab11d34dc477f48c3a1
|
data/lib/rrrspec/web.rb
CHANGED
data/lib/rrrspec/web/api.rb
CHANGED
@@ -6,56 +6,6 @@ module RRRSpec
|
|
6
6
|
module Web
|
7
7
|
DEFAULT_PER_PAGE = 10
|
8
8
|
|
9
|
-
class API < Grape::API
|
10
|
-
version 'v1', using: :path
|
11
|
-
format :json
|
12
|
-
set :per_page, DEFAULT_PER_PAGE
|
13
|
-
|
14
|
-
resource :tasksets do
|
15
|
-
desc "Return active tasksets"
|
16
|
-
get :actives do
|
17
|
-
ActiveTaskset.list
|
18
|
-
end
|
19
|
-
|
20
|
-
desc "Return recently finished tasksets"
|
21
|
-
get :recents do
|
22
|
-
paginate(RRRSpec::Server::Persistence::Taskset.recent).map(&:as_json_with_no_relation)
|
23
|
-
end
|
24
|
-
|
25
|
-
desc "Return tasksets that contains failure_exit slave"
|
26
|
-
get :failure_slaves do
|
27
|
-
paginate(RRRSpec::Server::Persistence::Taskset.has_failed_slaves.recent).map(&:as_json_with_no_relation)
|
28
|
-
end
|
29
|
-
|
30
|
-
desc "Return a taskset."
|
31
|
-
params { requires :key, type: String, desc: "Taskset key." }
|
32
|
-
route_param :key do
|
33
|
-
get do
|
34
|
-
p_obj = RRRSpec::Server::Persistence::Taskset.where(key: params[:key]).full.first
|
35
|
-
if p_obj
|
36
|
-
p_obj.as_full_json.update('is_full' => true)
|
37
|
-
else
|
38
|
-
error!('Not Found', 404)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
namespace :batch do
|
45
|
-
resource :tasks do
|
46
|
-
desc "Return all tasks in the taskset"
|
47
|
-
params { requires :key, type: String, desc: "Taskset key." }
|
48
|
-
route_param :key do
|
49
|
-
get do
|
50
|
-
r_taskset = Taskset.new(params[:key])
|
51
|
-
error!('Not Found', 404) unless r_taskset.exist?
|
52
|
-
r_taskset.tasks.map(&:to_h)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
9
|
module OjFormatter
|
60
10
|
def self.call(object, env)
|
61
11
|
Oj.dump(object, mode: :compat, time_format: :ruby)
|
data/lib/rrrspec/web/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module RRRSpec
|
4
|
-
describe
|
4
|
+
RSpec.describe Web do
|
5
5
|
before do
|
6
6
|
RRRSpec.configuration = Web::WebConfiguration.new
|
7
7
|
RRRSpec.configuration.redis = @redis
|
@@ -73,69 +73,6 @@ module RRRSpec
|
|
73
73
|
worker_log.set_finished_time
|
74
74
|
end
|
75
75
|
|
76
|
-
describe Web::API do
|
77
|
-
include Rack::Test::Methods
|
78
|
-
|
79
|
-
def app
|
80
|
-
Web::API
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "GET /v1/tasksets/actives" do
|
84
|
-
before { ActiveTaskset.add(taskset) }
|
85
|
-
|
86
|
-
it 'returns the active tasksets' do
|
87
|
-
get "/v1/tasksets/actives"
|
88
|
-
expect(last_response.status).to eq(200)
|
89
|
-
expect(JSON.parse(last_response.body)).to eq(JSON.parse(ActiveTaskset.list.to_json))
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "GET /v1/tasksets/recents" do
|
94
|
-
context 'there are 11 tasksets' do
|
95
|
-
before do
|
96
|
-
11.times { Server::Persistence::Taskset.create() }
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'returns the recent 10 tasksets' do
|
100
|
-
get "/v1/tasksets/recents"
|
101
|
-
expect(last_response.status).to eq(200)
|
102
|
-
expect(JSON.parse(last_response.body).size).to eq(10)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "GET /v1/tasksets/:key" do
|
108
|
-
context 'with the taskset persisted' do
|
109
|
-
before do
|
110
|
-
Server::Persister.persist(taskset)
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'returns the taskset' do
|
114
|
-
get "/v1/tasksets/#{taskset.key}"
|
115
|
-
expect(last_response.status).to eq(200)
|
116
|
-
expect(JSON.parse(last_response.body)).to eq(
|
117
|
-
JSON.parse(JSON.generate(Server::Persistence::Taskset.first.as_full_json)).update("is_full" => true)
|
118
|
-
)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'with the taskset not persisted' do
|
123
|
-
it 'returns 404' do
|
124
|
-
get "/v1/tasksets/#{taskset.key}"
|
125
|
-
expect(last_response.status).to eq(404)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe "GET /v1/batch/tasks/:key" do
|
131
|
-
it 'returns all tasks in the taskset' do
|
132
|
-
get "/v1/batch/tasks/#{taskset.key}"
|
133
|
-
expect(last_response.status).to eq(200)
|
134
|
-
expect(JSON.parse(last_response.body)).to eq([JSON.parse(task.to_json)])
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
76
|
describe Web::APIv2 do
|
140
77
|
include Rack::Test::Methods
|
141
78
|
|
@@ -150,7 +87,7 @@ module RRRSpec
|
|
150
87
|
get "/v2/tasksets/actives"
|
151
88
|
expect(last_response.status).to eq(200)
|
152
89
|
expect(JSON.parse(last_response.body)).to eq([
|
153
|
-
{ 'key' => taskset.key },
|
90
|
+
{ 'key' => taskset.key, 'status' => taskset.status, 'rsync_name' => taskset.rsync_name, 'created_at' => taskset.created_at.iso8601 },
|
154
91
|
])
|
155
92
|
end
|
156
93
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,7 +9,8 @@ require 'rack/test'
|
|
9
9
|
require 'database_cleaner'
|
10
10
|
|
11
11
|
RSpec.configure do |config|
|
12
|
-
config.
|
12
|
+
config.raise_errors_for_deprecations!
|
13
|
+
config.disable_monkey_patching!
|
13
14
|
config.run_all_when_everything_filtered = true
|
14
15
|
config.filter_run :focus
|
15
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rrrspec-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaya Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|