[PATCH conductor 1/1] pools api - rebase index endpoint.

Richard Su rwsu at redhat.com
Wed Aug 15 00:16:00 UTC 2012


On 08/14/2012 04:14 PM, Crag Wolfe wrote:
> Overrides previous two patches sent to list, rebased to master.
> ---
>   src/app/controllers/pools_controller.rb         |    3 +++
>   src/app/views/api/entrypoint/index.xml.haml     |    1 +
>   src/app/views/pools/_list.xml.haml              |    4 ++++
>   src/features/pool_api.feature                   |   16 ++++++++++++++++
>   src/features/step_definitions/pool_api_steps.rb |   12 ++++++++++++
>   5 files changed, 36 insertions(+), 0 deletions(-)
>   create mode 100644 src/app/views/pools/_list.xml.haml
>   create mode 100644 src/features/pool_api.feature
>   create mode 100644 src/features/step_definitions/pool_api_steps.rb
>
> diff --git a/src/app/controllers/pools_controller.rb b/src/app/controllers/pools_controller.rb
> index 931d25d..16ad93b 100644
> --- a/src/app/controllers/pools_controller.rb
> +++ b/src/app/controllers/pools_controller.rb
> @@ -109,6 +109,9 @@ class PoolsController < ApplicationController
>             :user_info => view_context.user_info_for_mustache
>           }
>         end
> +      format.xml do
> +        render :partial => 'list.xml'
> +      end
>       end
>     end
>
> diff --git a/src/app/views/api/entrypoint/index.xml.haml b/src/app/views/api/entrypoint/index.xml.haml
> index f3a1d92..597edbc 100644
> --- a/src/app/views/api/entrypoint/index.xml.haml
> +++ b/src/app/views/api/entrypoint/index.xml.haml
> @@ -2,5 +2,6 @@
>   %api{:href => api_url}
>     %images{:href => api_images_url}
>     %builds{:href => api_builds_url}
> +  %pools{:href => api_pools_url}
>     %provider_images{:href => api_provider_images_url}
>     %target_images{:href => api_target_images_url}
> diff --git a/src/app/views/pools/_list.xml.haml b/src/app/views/pools/_list.xml.haml
> new file mode 100644
> index 0000000..c9c3982
> --- /dev/null
> +++ b/src/app/views/pools/_list.xml.haml
> @@ -0,0 +1,4 @@
> +!!! XML
> +%pools
> +  - @pools.each do |pool|
> +    %pool{:id => pool.id, :href => api_pool_url(pool)}
> diff --git a/src/features/pool_api.feature b/src/features/pool_api.feature
> new file mode 100644
> index 0000000..6800f41
> --- /dev/null
> +++ b/src/features/pool_api.feature
> @@ -0,0 +1,16 @@
> + at api
> +Feature: Manage Pools via API
> +  As a client of conductor,
> +  In order to manage the full life cycle of pools in the system
> +  I want to be able to Create, Update and Delete pools via a RESTful API
> +
> +  Background:
> +    Given I am an authorised user
> +    And I use my authentication credentials in each request
> +
> +  Scenario: Get list of pools as XML
> +    Given a pool "foo" exists
> +    And a pool "bar" exists
> +    When I request a list of pools as XML
> +    # The third pool besides foo and bar is the Default pool
> +    Then I should receive list of 3 pools as XML
> diff --git a/src/features/step_definitions/pool_api_steps.rb b/src/features/step_definitions/pool_api_steps.rb
> new file mode 100644
> index 0000000..60e631b
> --- /dev/null
> +++ b/src/features/step_definitions/pool_api_steps.rb
> @@ -0,0 +1,12 @@
> +When /^I request a list of pools as XML$/ do
> +  header 'Accept', 'application/xml'
> +  get api_pools_path
> +end
> +
> +Then /^I should receive list of (\d+) pools as XML$/ do |number|
> +  response = last_response
> +  response.headers['Content-Type'].should include('application/xml')
> +  response.status.should be_eql(200)
> +  xml_body = Nokogiri::XML(response.body)
> +  xml_body.xpath('//pools/pool').size.should be_eql(number.to_i)
> +end
Hi Crag,

The pool name is missing in the xml response. And the test should assert 
that name and id are present and have correct values.

- Richard



More information about the aeolus-devel mailing list