cfoundry 2.3.6 → 2.3.7.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,16 @@ module CFoundry
28
28
  )
29
29
  )
30
30
  end
31
+
32
+ #
33
+ # def client.MODELs_first_page
34
+ #
35
+ define_method(:"#{plural}_first_page") do |*args|
36
+ get("v2", plural,
37
+ :accept => :json,
38
+ :params => ModelMagic.params_from(args)
39
+ )
40
+ end
31
41
  end
32
42
 
33
43
 
@@ -70,6 +80,20 @@ module CFoundry
70
80
  end
71
81
  end
72
82
 
83
+ #
84
+ # def client.MODELs_first_page
85
+ #
86
+ define_method(:"#{plural}_first_page") do |*args|
87
+ response = @base.send(:"#{plural}_first_page", *args)
88
+ results = response[:resources].collect do |json|
89
+ send(:"make_#{singular}", json)
90
+ end
91
+ {
92
+ :next_page => !!response[:next_url],
93
+ :results => results
94
+ }
95
+ end
96
+
73
97
  #
74
98
  # def client.MODEL_from
75
99
  #
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "2.3.6".freeze
3
+ VERSION = "2.3.7.rc1".freeze
4
4
  end
@@ -347,6 +347,43 @@ module CFoundry
347
347
  end
348
348
  end
349
349
  end
350
+
351
+ describe "first_page" do
352
+ before do
353
+ WebMock.stub_request(:get, /v2\/test_models/).to_return(:body => {
354
+ "prev_url" => nil,
355
+ "next_url" => next_url,
356
+ "resources" => [{:metadata => {:guid => '1234'}}]
357
+ }.to_json)
358
+ end
359
+
360
+ context "when there is a next page" do
361
+ let(:next_url) { "/v2/test_models?&page=2&results-per-page=50" }
362
+ before do
363
+ WebMock.stub_request(:get, /v2\/test_models/).to_return(:body => {
364
+ "prev_url" => nil,
365
+ "next_url" => "/v2/test_models?&page=2&results-per-page=50",
366
+ "resources" => [{:metadata => {:guid => '1234'}}]
367
+ }.to_json)
368
+ end
369
+
370
+ it "has next_page set to true" do
371
+ results = client.test_models_first_page
372
+ results[:next_page].should be_true
373
+ results[:results].length.should == 1
374
+ results[:results].first.should be_a TestModel
375
+ end
376
+ end
377
+
378
+ context "when there is no next page" do
379
+ let(:next_url) { nil }
380
+
381
+ it "has next_page set to false" do
382
+ results = client.test_models_first_page
383
+ results[:next_page].should be_false
384
+ end
385
+ end
386
+ end
350
387
  end
351
388
  end
352
389
  end
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: 2.3.6
5
- prerelease:
4
+ version: 2.3.7.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cloud Foundry Team
@@ -416,16 +416,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
416
416
  version: '0'
417
417
  segments:
418
418
  - 0
419
- hash: 1225094362336232528
419
+ hash: 3694164670967481672
420
420
  required_rubygems_version: !ruby/object:Gem::Requirement
421
421
  none: false
422
422
  requirements:
423
- - - ! '>='
423
+ - - ! '>'
424
424
  - !ruby/object:Gem::Version
425
- version: '0'
426
- segments:
427
- - 0
428
- hash: 1225094362336232528
425
+ version: 1.3.1
429
426
  requirements: []
430
427
  rubyforge_project: cfoundry
431
428
  rubygems_version: 1.8.25