This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
/
names_spec.rb
59 lines (49 loc) · 2.27 KB
/
names_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require "spec_helper"
describe AppsController do
describe "Find or create app name" do
it "responds successfully with an HTTP 200 status code" do
post "/apps", app: "foo", branch: "feature-bar", servers: 2
expect(response).to be_success
expect(response.body).to eql("foo-staging-1")
# same branch
post "/apps", app: "foo", branch: "feature-bar", servers: 2
expect(response).to be_success
expect(response.body).to eql("foo-staging-1")
# other branch
post "/apps", app: "foo", branch: "feature-baz", servers: 2
expect(response).to be_success
expect(response.body).to eql("foo-staging-2")
# the first branch again
post "/apps", app: "foo", branch: "feature-bar", servers: 2
expect(response).to be_success
expect(response.body).to eql("foo-staging-1")
# another branch
post "/apps", app: "foo", branch: "feature-foo", servers: 2
expect(response).to be_success
expect(response.body).to eql("foo-staging-2")
# incresed server
post "/apps", app: "foo", branch: "feature-zzz", servers: 3
expect(response).to be_success
expect(response.body).to eql("foo-staging-3")
# reduced server
Timecop.freeze do
post "/apps", app: "foo", branch: "feature-zzz", servers: 1
expect(response).to be_success
expect(response.body).to eql("foo-staging-1")
post "/apps", app: "bar", branch: "feature-xxx", servers: 1
expect(response).to be_success
expect(response.body).to eql("bar-staging-1")
get "/apps", {format: :json}, http_auth_header
expect(response).to be_success
expect(JSON.parse(response.body)).to eql([{"name" => "bar",
"servers" =>
[{"branch_name" => "feature-xxx",
"last_use" => Time.now.as_json}]},
{"name" => "foo",
"servers" =>
[{"branch_name" => "feature-zzz",
"last_use" => Time.now.as_json}]}])
end
end
end
end