Couple minor nits/suggestions inline, ACK otherwise, beautiful :)

On Mon, 2010-08-02 at 14:50 +0200, jprov...@redhat.com wrote:
> From: Jan Provaznik <jprov...@redhat.com>
> 
> ---
>  src/app/views/permissions/list.html.erb           |    2 +-
>  src/features/permission.feature                   |   36 
> +++++++++++++++++++++
>  src/features/step_definitions/permission_steps.rb |   19 +++++++++++
>  src/features/support/paths.rb                     |    6 +++
>  4 files changed, 62 insertions(+), 1 deletions(-)
>  create mode 100644 src/features/permission.feature
>  create mode 100644 src/features/step_definitions/permission_steps.rb
> 
> diff --git a/src/app/views/permissions/list.html.erb 
> b/src/app/views/permissions/list.html.erb
> index e935411..862a32f 100644
> --- a/src/app/views/permissions/list.html.erb
> +++ b/src/app/views/permissions/list.html.erb
> @@ -18,7 +18,7 @@
>              <% if has_set_perms? %>
>                <% form_tag :action => 'destroy' do %>
>                  <%= hidden_field :permission, :id, :value => permission.id %>
> -                <%= submit_tag "delete", :class => "submit_link" %>
> +                <%= submit_tag "delete", :class => "submit_link", :id => 
> "delete_#{permission.id}" %>
>                <% end %>
>              <% end %>
>            </td>
> diff --git a/src/features/permission.feature b/src/features/permission.feature
> new file mode 100644
> index 0000000..0dd15b5
> --- /dev/null
> +++ b/src/features/permission.feature
> @@ -0,0 +1,36 @@
> +Feature: Manage Permissions
> +  In order to manage permissions
> +  As an admin
> +  I want to add/remove a permission for an user

s/'an user'/'a user' above
> +
> +  Background:
> +    Given I am an authorised user
> +    And I am logged in
> +    And a user "testuser" exists
> +
> +  Scenario: Create a new Permission
> +       Given I am on the permissions page
> +       And there is not a permission for the user "testuser"
> +       When I follow "Add a new permission record"
> +       Then I should be on the new permission page
> +       And I should see "new Permission"
> +       When I select "testuser" from "permission[user_id]"
> +       And I select "Provider Creator" from "permission[role_id]"
> +       And I press "Save"
> +       Then I should be on the permissions page
> +       And I should see "Permission record added"
> +       And I should see "testuser"
> +
> +  Scenario: Create a permission which already exists
> +       Given there is a permission for the user "testuser"
> +       And I am on the new permission page
> +       When I select "testuser" from "permission[user_id]"
> +       And I select "Provider Creator" from "permission[role_id]"
> +       And I press "Save"
> +       Then I should stay on the new permission page
> +
> +  Scenario: Delete a permission
> +    Given there is a permission for the user "testuser"
> +    And I am on the permissions page
> +    When I delete the permission
> +    Then I should be on the permissions page
> diff --git a/src/features/step_definitions/permission_steps.rb 
> b/src/features/step_definitions/permission_steps.rb
> new file mode 100644
> index 0000000..4ebcca9
> --- /dev/null
> +++ b/src/features/step_definitions/permission_steps.rb
> @@ -0,0 +1,19 @@
> +Given /^a user "([^\"]*)" exists$/ do |login|
> +  @user = Factory(:user, :login => login)
> +end
> +
> +Given /^there is not a permission for the user "([^\"]*)"$/ do |login|
> +  Permission.first(:include => 'user', :conditions => ['users.login = ?', 
> login]).should be_nil
> +end
> +
> +Given /^there is a permission for the user "([^\"]*)"$/ do |login|
> +  @admin_permission = Factory(:admin_permission, :user_id => @user.id)
> +end
> +
> +Given /^I should stay on the new permission page$/ do
> +  response.should contain "new Permission"
> +end

This explicit check should only be needed for dynamic, like a user name,
otherwise webrat should find the text on the page for you with no extra
work.

> +
> +Given /^I delete the permission$/ do
> +  click_button "delete...@admin_permission.id}"
> +end
> diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
> index db20948..b790348 100644
> --- a/src/features/support/paths.rb
> +++ b/src/features/support/paths.rb
> @@ -50,6 +50,12 @@ module NavigationHelpers
>      when /the pool hardware profiles page/
>        hardware_profiles_pool_path
>  
> +    when /the permissions page/
> +      url_for :action => 'list', :controller => 'permissions', :only_path => 
> true
> +
> +    when /the new permission page/
> +      url_for :action => 'new', :controller => 'permissions', :only_path => 
> true
> +
>      # Add more mappings here.
>      # Here is an example that pulls values out of the Regexp:
>      #


_______________________________________________
deltacloud-devel mailing list
deltacloud-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to