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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bab0dd77260b7d366397bd02fb6f4766b4ba7f47
4
- data.tar.gz: 152e8e61b2bcdac3c7dc7fe1fe27e8a1688a67f1
3
+ metadata.gz: 6cba09c2e05c47bef0f93009f6f11e19003f1506
4
+ data.tar.gz: 2d5d4c20884ac93e1b6d110b17b1d927b5cf49a7
5
5
  SHA512:
6
- metadata.gz: 8b4c3d9947f0f1ddf908e590292578c6710f00cfff5090e9dcf9abcbf4a057d4fabd947a6c0480e77a4877be67fbf139cf54d74be9199542ecdcc86baa761af4
7
- data.tar.gz: 0404b4013395496b738756d993c63f2e94c9deb72850d51128547b80d7afb9b419897bdd3eac96119209cee3fe80a0b6b2aabff6c42572e843174fd0d6a4cb31
6
+ metadata.gz: 938a8d116ac1452cac229553283ec3e4f6b00f097b7beccaf36baaa77052361251a2d1287e2fb095ea16c9e813e85dddb0992bd7f6024deb8b71b8a021aff3fb
7
+ data.tar.gz: 8198e8b595765180b9d02204056ae7afde7e1ef12029bc4f15508f201ccec45cf8da80e41d01fb5862b576e7c82a47bba1a4146afd8875bb39bbd01ede9673c6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- magellan-cli (0.6.2)
4
+ magellan-cli (0.6.3)
5
5
  activesupport (~> 4.1.4)
6
6
  groovenauts-thor
7
7
  httpclient (~> 2.5)
@@ -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 = build_query("name" => name).update(default_query)
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
@@ -1,5 +1,5 @@
1
1
  module Magellan
2
2
  module Cli
3
- VERSION = "0.6.2"
3
+ VERSION = "0.6.3"
4
4
  end
5
5
  end
@@ -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][2][o]"=>"is", "f[name][2][v]"=> org_name}).and_return(organization_list_response)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magellan-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - akm2000