cfoundry 4.3.4 → 4.3.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -120,7 +120,7 @@ module CFoundry::V2
120
120
  end
121
121
  end
122
122
 
123
- @manifest = @client.base.post("v2", plural_object_name,
123
+ @manifest = @client.base.post("v2", create_endpoint_name,
124
124
  :content => :json,
125
125
  :accept => :json,
126
126
  :payload => payload
@@ -133,6 +133,10 @@ module CFoundry::V2
133
133
  true
134
134
  end
135
135
 
136
+ def create_endpoint_name
137
+ plural_object_name
138
+ end
139
+
136
140
  def update!
137
141
  @manifest = @client.base.put("v2", plural_object_name, guid,
138
142
  :content => :json,
@@ -3,5 +3,13 @@ require "cfoundry/v2/service_instance"
3
3
  module CFoundry::V2
4
4
  class UserProvidedServiceInstance < ServiceInstance
5
5
  attribute :credentials, :hash
6
+
7
+ def self.object_name
8
+ 'service_instance'
9
+ end
10
+
11
+ def create_endpoint_name
12
+ 'user_provided_service_instances'
13
+ end
6
14
  end
7
15
  end
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "4.3.4".freeze
3
+ VERSION = "4.3.5.rc1".freeze
4
4
  end
@@ -1,12 +1,22 @@
1
1
  require "spec_helper"
2
2
 
3
- class TestModel < CFoundry::V2::Model
4
- attribute :foo, :string
5
- to_one :domain
6
- end
7
-
8
3
  module CFoundry
9
4
  module V2
5
+
6
+ # be careful, there is a TestModel in global scope because of the TestModelBuilder
7
+ class TestModel < CFoundry::V2::Model
8
+ attribute :foo, :string
9
+ to_one :domain
10
+
11
+ def create_endpoint_name
12
+ :odd_endpoint
13
+ end
14
+ end
15
+
16
+ class DefaultTestModel < CFoundry::V2::Model
17
+ attribute :foo, :string
18
+ end
19
+
10
20
  describe Model do
11
21
  let(:client) { build(:client) }
12
22
  let(:guid) { "my-object-guid" }
@@ -69,7 +79,7 @@ module CFoundry
69
79
  end
70
80
 
71
81
  it "posts to the model's create url with appropriate arguments" do
72
- client.base.should_receive(:post).with("v2", :test_models,
82
+ client.base.should_receive(:post).with("v2", :odd_endpoint,
73
83
  :content => :json,
74
84
  :accept => :json,
75
85
  :payload => {:foo => "bar"}
@@ -411,6 +421,13 @@ module CFoundry
411
421
  end
412
422
  end
413
423
 
424
+ describe "#create_endpoint_name" do
425
+ let(:default_model) { DefaultTestModel.new(guid, client, manifest) }
426
+
427
+ it "defaults to the plural object name" do
428
+ expect(default_model.create_endpoint_name).to eq(:default_test_models)
429
+ end
430
+ end
414
431
  end
415
432
  end
416
433
  end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  module CFoundry
4
4
  module V2
@@ -6,22 +6,52 @@ module CFoundry
6
6
  let(:client) { build(:client) }
7
7
  subject { build(:user_provided_service_instance, :client => client) }
8
8
 
9
- describe "space" do
9
+ describe 'space' do
10
10
  let(:space) { build(:space) }
11
11
 
12
- it "has a space" do
12
+ it 'has a space' do
13
13
  subject.space = space
14
14
  expect(subject.space).to eq(space)
15
15
  end
16
16
 
17
- context "when an invalid value is assigned" do
18
- it "raises a Mismatch exception" do
17
+ context 'when an invalid value is assigned' do
18
+ it 'raises a Mismatch exception' do
19
19
  expect {
20
20
  subject.space = [build(:organization)]
21
21
  }.to raise_error(CFoundry::Mismatch)
22
22
  end
23
23
  end
24
24
  end
25
+
26
+ describe 'creating' do
27
+ let(:body) {
28
+ {
29
+ 'metadata' => {
30
+ 'guid' => 'someguid'
31
+ }
32
+ }.to_json
33
+ }
34
+
35
+ it 'calls the correct endpoint' do
36
+ stub_request(:any, %r[.*]).
37
+ to_return(:body => body, :status => 200)
38
+
39
+ subject.create!
40
+
41
+ a_request(:post, 'http://api.example.com/v2/user_provided_service_instances').should have_been_made
42
+ end
43
+ end
44
+
45
+ describe 'deleting' do
46
+ it 'calls the correct endpoint' do
47
+ stub_request(:any, %r[.*])
48
+
49
+ subject.delete!
50
+
51
+ a_request(:delete, "http://api.example.com/v2/service_instances/#{subject.guid}").should have_been_made
52
+ end
53
+ end
25
54
  end
26
55
  end
27
56
  end
57
+
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfoundry
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.4
5
- prerelease:
4
+ version: 4.3.5.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cloud Foundry Team
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-15 00:00:00.000000000 Z
13
+ date: 2013-08-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
@@ -450,16 +450,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
450
450
  version: '0'
451
451
  segments:
452
452
  - 0
453
- hash: -4469232100835687560
453
+ hash: -3354893909310482905
454
454
  required_rubygems_version: !ruby/object:Gem::Requirement
455
455
  none: false
456
456
  requirements:
457
- - - ! '>='
457
+ - - ! '>'
458
458
  - !ruby/object:Gem::Version
459
- version: '0'
460
- segments:
461
- - 0
462
- hash: -4469232100835687560
459
+ version: 1.3.1
463
460
  requirements: []
464
461
  rubyforge_project: cfoundry
465
462
  rubygems_version: 1.8.25