magellan-cli 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/magellan/cli/resources/base.rb +1 -1
- data/lib/magellan/cli/resources/client_version.rb +9 -0
- data/lib/magellan/cli/resources/stage.rb +7 -1
- data/lib/magellan/cli/version.rb +1 -1
- data/spec/magellan/cli/resources/client_version_spec.rb +19 -1
- data/spec/magellan/cli/resources/organization_spec.rb +1 -1
- data/spec/magellan/cli/resources/project_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cba09c2e05c47bef0f93009f6f11e19003f1506
|
4
|
+
data.tar.gz: 2d5d4c20884ac93e1b6d110b17b1d927b5cf49a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 938a8d116ac1452cac229553283ec3e4f6b00f097b7beccaf36baaa77052361251a2d1287e2fb095ea16c9e813e85dddb0992bd7f6024deb8b71b8a021aff3fb
|
7
|
+
data.tar.gz: 8198e8b595765180b9d02204056ae7afde7e1ef12029bc4f15508f201ccec45cf8da80e41d01fb5862b576e7c82a47bba1a4146afd8875bb39bbd01ede9673c6
|
data/Gemfile.lock
CHANGED
@@ -78,7 +78,7 @@ module Magellan
|
|
78
78
|
res = obj[:resource] || ((k = Resources.const_get(obj[:class])) ? k.resource_key : nil)
|
79
79
|
res2 = get_json("/admin/#{res}.json", {"compact" => true})
|
80
80
|
attr_name = (k ? k.caption_attr : nil) || "caption"
|
81
|
-
associations[f] = res2.each_with_object({}){|r,d| d[ r["id"].to_i ] = r[attr_name] }
|
81
|
+
associations[f] = res2.each_with_object({}){|r,d| d[ r["id"].to_i ] = r[attr_name] || r["label"] }
|
82
82
|
end
|
83
83
|
return associations
|
84
84
|
end
|
@@ -41,9 +41,18 @@ module Magellan
|
|
41
41
|
else
|
42
42
|
attrs = JSON.parse(attrs)
|
43
43
|
end
|
44
|
+
stage_name = attrs.delete("stage")
|
45
|
+
|
44
46
|
cv = load_selection!(self.class)
|
45
47
|
self.class.hidden_fields.each do |f| attrs.delete(f) end
|
46
48
|
self.class.field_associations.keys.each do |f| attrs.delete(f) end
|
49
|
+
|
50
|
+
unless stage_name.blank?
|
51
|
+
q = Stage.new.build_name_query(stage_name)
|
52
|
+
r = get_first_result!(Stage.parameter_name, stage_name, "/admin/stage~title.json", q)
|
53
|
+
attrs["stage_title_id"] = r["id"]
|
54
|
+
end
|
55
|
+
|
47
56
|
params = {
|
48
57
|
parameter_name => attrs
|
49
58
|
}
|
@@ -36,13 +36,19 @@ module Magellan
|
|
36
36
|
select(name)
|
37
37
|
end
|
38
38
|
|
39
|
+
no_commands do
|
40
|
+
def build_name_query(name)
|
41
|
+
build_query("name" => name).update(default_query)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
39
45
|
desc "select NAME", I18n.t(:select, scope: [:resources, :common, :cmd], res_name: resource_name)
|
40
46
|
def select(name)
|
41
47
|
if selected = load_selections[parameter_name]
|
42
48
|
deselect unless selected["name"] == name
|
43
49
|
end
|
44
50
|
|
45
|
-
q =
|
51
|
+
q = build_name_query(name)
|
46
52
|
r = update_first_result(parameter_name, name, "/admin/stage~title.json", q)
|
47
53
|
|
48
54
|
# # current
|
data/lib/magellan/cli/version.rb
CHANGED
@@ -62,7 +62,8 @@ describe Magellan::Cli::Resources::ClientVersion do
|
|
62
62
|
let(:selections) do
|
63
63
|
{
|
64
64
|
Magellan::Cli::Resources::Project.parameter_name => {"id" => 1, "name" => "ProjectA"},
|
65
|
-
Magellan::Cli::Resources::ClientVersion.parameter_name => {"id" => 1, "version" => "Sandbox1"}
|
65
|
+
Magellan::Cli::Resources::ClientVersion.parameter_name => {"id" => 1, "version" => "Sandbox1"},
|
66
|
+
Magellan::Cli::Resources::Stage.parameter_name => {"id" => 1, "name" => "Stage1"},
|
66
67
|
}
|
67
68
|
end
|
68
69
|
describe :success_to_update_domain do
|
@@ -74,6 +75,23 @@ describe Magellan::Cli::Resources::ClientVersion do
|
|
74
75
|
cmd.update('{"domain": "bar.example.com"}')
|
75
76
|
end
|
76
77
|
end
|
78
|
+
|
79
|
+
describe :success_to_update_stage do
|
80
|
+
let(:st_id){ 2 }
|
81
|
+
let(:st_name){ "Stage2" }
|
82
|
+
before do
|
83
|
+
allow_any_instance_of(Magellan::Cli::Resources::Stage).to receive(:http_conn).and_return(http_conn)
|
84
|
+
allow_any_instance_of(Magellan::Cli::Resources::Stage).to receive(:load_selections).and_return(selections)
|
85
|
+
allow(cmd).to receive(:load_selections).and_return(selections)
|
86
|
+
expect(http_conn).to receive(:get_json).with("/admin/stage~title.json", {"f[name][1][o]"=>"is", "f[name][1][v]"=>st_name, "f[project][2][o]"=>"is", "f[project][2][v]"=>1}).
|
87
|
+
and_return([{"id" => st_id, "name" => st_name}])
|
88
|
+
expect(cmd).to receive(:put_json).with("/admin/client_version/1/edit.json", { "client_version" => { "stage_title_id" => st_id } })
|
89
|
+
end
|
90
|
+
it do
|
91
|
+
cmd.update('{"stage": "Stage2"}')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
77
95
|
end
|
78
96
|
|
79
97
|
end
|
@@ -34,7 +34,7 @@ describe Magellan::Cli::Resources::Organization do
|
|
34
34
|
let(:org_name){ "org5" }
|
35
35
|
let(:organization_list_response) { [ { "id" => org_id, "name" => org_name } ] }
|
36
36
|
before do
|
37
|
-
allow(http_conn).to receive(:get_json).with("/admin/magellan~auth~organization.json", {"f[name][
|
37
|
+
allow(http_conn).to receive(:get_json).with("/admin/magellan~auth~organization.json", {"f[name][5][o]"=>"is", "f[name][5][v]"=> org_name}).and_return(organization_list_response)
|
38
38
|
allow(http_conn).to receive(:delete).with("/admin/magellan~auth~organization/5/delete")
|
39
39
|
end
|
40
40
|
it do
|
@@ -32,7 +32,7 @@ describe Magellan::Cli::Resources::Project do
|
|
32
32
|
$stdout, backup = buf, $stdout
|
33
33
|
begin
|
34
34
|
expect(httpclient).to receive(:get).with(%{#{base_url}/admin/project.json}).and_return(list_res)
|
35
|
-
expect(httpclient).to receive(:get).with(%{#{base_url}/admin/magellan~auth~organization.json}).and_return(org_res)
|
35
|
+
expect(httpclient).to receive(:get).with(%{#{base_url}/admin/magellan~auth~organization.json?compact=true}).and_return(org_res)
|
36
36
|
cmd.list
|
37
37
|
buf.rewind
|
38
38
|
output = buf.read
|