From 8e81a7b643e61bdcbec2fa916adf7bc31ebfa55e Mon Sep 17 00:00:00 2001 From: Renan Fichberg Date: Fri, 17 Jan 2014 16:28:18 -0200 Subject: [PATCH] Finished Edit Reading Group View & AcceptanceTests --- app/views/reading_groups/edit.html.erb | 7 +++++++ app/views/shared/_reading_groups_list.erb | 1 - features/project/edition.feature | 2 +- features/reading_group/create.feature | 43 +++++++++++++++++++++++++++++++++++++++++++ features/reading_group/edit.feature | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ features/step_definitions/reading_group_steps.rb | 21 +++++++++++++++++++++ 6 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 features/reading_group/create.feature create mode 100644 features/reading_group/edit.feature diff --git a/app/views/reading_groups/edit.html.erb b/app/views/reading_groups/edit.html.erb index e69de29..955ae43 100644 --- a/app/views/reading_groups/edit.html.erb +++ b/app/views/reading_groups/edit.html.erb @@ -0,0 +1,7 @@ + + +<%= render 'form' %> + +<%= link_to 'Back', reading_group_path %> diff --git a/app/views/shared/_reading_groups_list.erb b/app/views/shared/_reading_groups_list.erb index fc8d564..c5147fc 100644 --- a/app/views/shared/_reading_groups_list.erb +++ b/app/views/shared/_reading_groups_list.erb @@ -9,7 +9,6 @@ <% reading_groups.each do |reading_group| %> - <% p reading_group %> <%= reading_group.name %> <%= reading_group.description %> diff --git a/features/project/edition.feature b/features/project/edition.feature index 35e5bd3..d2d3881 100644 --- a/features/project/edition.feature +++ b/features/project/edition.feature @@ -3,7 +3,7 @@ Feature: Project As a regular user I should be able to edit my projects - @kalibro_restart + @kalibro_restarts Scenario: Should go to the edit page from a project that I own Given I am a regular user And I am signed in diff --git a/features/reading_group/create.feature b/features/reading_group/create.feature new file mode 100644 index 0000000..a829d71 --- /dev/null +++ b/features/reading_group/create.feature @@ -0,0 +1,43 @@ +Feature: Reading Group Creation + In order to create new reading groups to make my own readings + As a regular user + I should be able to create reading groups + +@kalibro_restart +Scenario: Should not create reading groups without login + Given I am at the All Reading Groups page + Then I should not see New Reading Group + +@kalibro_restart +Scenario: Reading Group creation + Given I am a regular user + And I am signed in + And I am at the New Reading Group page + And I fill the Name field with "My reading group" + And I fill the Description field with "New reading group" + When I press the Save button + Then I should see "My reading group" + And I should see "New reading group" + And I should see "New Reading" + And I should see "Destroy Reading Group" + +@kalibro_restart +Scenario: reading group creation with already taken name + Given I am a regular user + And I am signed in + And I have a reading group named "Group" + And I am at the New Reading Group page + And I fill the Name field with "Group" + And I fill the Description field with "Same Group" + When I press the Save button + Then I should see "There's already" + +@kalibro_restart +Scenario: reading group creation with blank name + Given I am a regular user + And I am signed in + And I am at the New Reading Group page + And I fill the Name field with " " + And I fill the Description field with "Anything" + When I press the Save button + Then I should see "Name can't be blank" \ No newline at end of file diff --git a/features/reading_group/edit.feature b/features/reading_group/edit.feature new file mode 100644 index 0000000..f144e6e --- /dev/null +++ b/features/reading_group/edit.feature @@ -0,0 +1,83 @@ +Feature: Reading Group + In Order to be able to update my reading groups info + As a regular user + I should be able to edit my reading groups + + @kalibro_restart + Scenario: Should go to the edit page from a reading group that I own + Given I am a regular user + And I am signed in + And I have a sample reading group + And I am at the All Reading Groups page + When I click the Edit link + Then I should be in the Edit Reading Group page + + @kalibro_restart + Scenario: Should not show edit links from reading groups that doesn't belongs to me + Given I am a regular user + And I am signed in + And I have a sample reading group + And I am at the All Reading Groups page + Then I should not see "Edit" within "table tr td" + + @kalibro_restart + Scenario: Should not render the edit page if the reading group doesn't belongs to the current user + Given I am a regular user + And I am signed in + And I have a sample reading group + And I am at the All Reading Groups page + When I visit the sample reading group edit page + Then I should see "You're not allowed to do this operation" + + @kalibro_restart + Scenario: Filling up the form + Given I am a regular user + And I am signed in + And I own a sample reading group + And I am at the All Reading Groups page + When I click the Edit link + Then The field "reading_group[name]" should be filled with the sample reading group "name" + And The field "reading_group[description]" should be filled with the sample reading group "description" + + @kalibro_restart + Scenario: With valid attributes + Given I am a regular user + And I am signed in + And I own a sample reading group + And I am at the sample reading group edit page + And I fill the Name field with "My Reading Group" + And I fill the Description field with "New Reading Group" + When I press the Save button + Then I should see "My Reading Group" + And I should see "New Reading Group" + + @kalibro_restart + Scenario: With reading group name already taken + Given I am a regular user + And I am signed in + And I have a reading group named "A Reading" + And I own a reading group named "My reading" + And I am at the sample reading group edit page + And I fill the Name field with "A Reading" + When I press the Save button + Then I should see "There's already" + + @kalibro_restart + Scenario: Editing just the description + Given I am a regular user + And I am signed in + And I own a sample reading group + And I am at the sample reading group edit page + And I fill the Description field with "New Reading Group" + When I press the Save button + Then I should see "New Reading Group" + + @kalibro_restart + Scenario: With blank reading group name + Given I am a regular user + And I am signed in + And I own a sample reading group + And I am at the sample reading group edit page + And I fill the Name field with " " + When I press the Save button + Then I should see "Name can't be blank" diff --git a/features/step_definitions/reading_group_steps.rb b/features/step_definitions/reading_group_steps.rb index 880ee84..5462598 100644 --- a/features/step_definitions/reading_group_steps.rb +++ b/features/step_definitions/reading_group_steps.rb @@ -25,6 +25,23 @@ Given(/^I visit the Sample Reading Group page$/) do visit reading_group_path(@reading_group.id) end +Given(/^I am at the sample reading group edit page$/) do + visit edit_reading_group_path(@reading_group.id) +end + +Given(/^I own a reading group named "(.*?)"$/) do |name| + @reading_group = FactoryGirl.create(:reading_group, {id: nil, name: name}) + FactoryGirl.create(:reading_group_ownership, {user_id: @user.id, reading_group_id: @reading_group.id}) +end + +When(/^I visit the sample reading group edit page$/) do + visit edit_reading_group_path(@reading_group.id) +end + +Then(/^The field "(.*?)" should be filled with the sample reading group "(.*?)"$/) do |field, value| + page.find_field(field).value.should eq(@reading_group.send(value)) +end + Then(/^I should be in the Sample Reading Group page$/) do page.should have_content(@reading_group.name) page.should have_content(@reading_group.description) @@ -37,4 +54,8 @@ Then(/^I should see the information of the sample reading$/) do color = @reading.color.downcase var = (pager =~ /#{color}/) var.should_not be_nil +end + +Then(/^I should be in the Edit Reading Group page$/) do + visit edit_reading_group_path(@reading_group.id) end \ No newline at end of file -- libgit2 0.21.2