Commit 8e81a7b643e61bdcbec2fa916adf7bc31ebfa55e
Committed by
Rafael Manzo
1 parent
09d282ff
Exists in
colab
and in
4 other branches
Finished Edit Reading Group View & AcceptanceTests
Signed-of By: Fellipe Souto Sampaio <fllsouto@gmail.com>
Showing
6 changed files
with
155 additions
and
2 deletions
Show diff stats
app/views/reading_groups/edit.html.erb
app/views/shared/_reading_groups_list.erb
| @@ -9,7 +9,6 @@ | @@ -9,7 +9,6 @@ | ||
| 9 | 9 | ||
| 10 | <tbody> | 10 | <tbody> |
| 11 | <% reading_groups.each do |reading_group| %> | 11 | <% reading_groups.each do |reading_group| %> |
| 12 | - <% p reading_group %> | ||
| 13 | <tr> | 12 | <tr> |
| 14 | <td><%= reading_group.name %></td> | 13 | <td><%= reading_group.name %></td> |
| 15 | <td><%= reading_group.description %></td> | 14 | <td><%= reading_group.description %></td> |
features/project/edition.feature
| @@ -3,7 +3,7 @@ Feature: Project | @@ -3,7 +3,7 @@ Feature: Project | ||
| 3 | As a regular user | 3 | As a regular user |
| 4 | I should be able to edit my projects | 4 | I should be able to edit my projects |
| 5 | 5 | ||
| 6 | - @kalibro_restart | 6 | + @kalibro_restarts |
| 7 | Scenario: Should go to the edit page from a project that I own | 7 | Scenario: Should go to the edit page from a project that I own |
| 8 | Given I am a regular user | 8 | Given I am a regular user |
| 9 | And I am signed in | 9 | And I am signed in |
| @@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
| 1 | +Feature: Reading Group Creation | ||
| 2 | + In order to create new reading groups to make my own readings | ||
| 3 | + As a regular user | ||
| 4 | + I should be able to create reading groups | ||
| 5 | + | ||
| 6 | +@kalibro_restart | ||
| 7 | +Scenario: Should not create reading groups without login | ||
| 8 | + Given I am at the All Reading Groups page | ||
| 9 | + Then I should not see New Reading Group | ||
| 10 | + | ||
| 11 | +@kalibro_restart | ||
| 12 | +Scenario: Reading Group creation | ||
| 13 | + Given I am a regular user | ||
| 14 | + And I am signed in | ||
| 15 | + And I am at the New Reading Group page | ||
| 16 | + And I fill the Name field with "My reading group" | ||
| 17 | + And I fill the Description field with "New reading group" | ||
| 18 | + When I press the Save button | ||
| 19 | + Then I should see "My reading group" | ||
| 20 | + And I should see "New reading group" | ||
| 21 | + And I should see "New Reading" | ||
| 22 | + And I should see "Destroy Reading Group" | ||
| 23 | + | ||
| 24 | +@kalibro_restart | ||
| 25 | +Scenario: reading group creation with already taken name | ||
| 26 | + Given I am a regular user | ||
| 27 | + And I am signed in | ||
| 28 | + And I have a reading group named "Group" | ||
| 29 | + And I am at the New Reading Group page | ||
| 30 | + And I fill the Name field with "Group" | ||
| 31 | + And I fill the Description field with "Same Group" | ||
| 32 | + When I press the Save button | ||
| 33 | + Then I should see "There's already" | ||
| 34 | + | ||
| 35 | +@kalibro_restart | ||
| 36 | +Scenario: reading group creation with blank name | ||
| 37 | + Given I am a regular user | ||
| 38 | + And I am signed in | ||
| 39 | + And I am at the New Reading Group page | ||
| 40 | + And I fill the Name field with " " | ||
| 41 | + And I fill the Description field with "Anything" | ||
| 42 | + When I press the Save button | ||
| 43 | + Then I should see "Name can't be blank" | ||
| 0 | \ No newline at end of file | 44 | \ No newline at end of file |
| @@ -0,0 +1,83 @@ | @@ -0,0 +1,83 @@ | ||
| 1 | +Feature: Reading Group | ||
| 2 | + In Order to be able to update my reading groups info | ||
| 3 | + As a regular user | ||
| 4 | + I should be able to edit my reading groups | ||
| 5 | + | ||
| 6 | + @kalibro_restart | ||
| 7 | + Scenario: Should go to the edit page from a reading group that I own | ||
| 8 | + Given I am a regular user | ||
| 9 | + And I am signed in | ||
| 10 | + And I have a sample reading group | ||
| 11 | + And I am at the All Reading Groups page | ||
| 12 | + When I click the Edit link | ||
| 13 | + Then I should be in the Edit Reading Group page | ||
| 14 | + | ||
| 15 | + @kalibro_restart | ||
| 16 | + Scenario: Should not show edit links from reading groups that doesn't belongs to me | ||
| 17 | + Given I am a regular user | ||
| 18 | + And I am signed in | ||
| 19 | + And I have a sample reading group | ||
| 20 | + And I am at the All Reading Groups page | ||
| 21 | + Then I should not see "Edit" within "table tr td" | ||
| 22 | + | ||
| 23 | + @kalibro_restart | ||
| 24 | + Scenario: Should not render the edit page if the reading group doesn't belongs to the current user | ||
| 25 | + Given I am a regular user | ||
| 26 | + And I am signed in | ||
| 27 | + And I have a sample reading group | ||
| 28 | + And I am at the All Reading Groups page | ||
| 29 | + When I visit the sample reading group edit page | ||
| 30 | + Then I should see "You're not allowed to do this operation" | ||
| 31 | + | ||
| 32 | + @kalibro_restart | ||
| 33 | + Scenario: Filling up the form | ||
| 34 | + Given I am a regular user | ||
| 35 | + And I am signed in | ||
| 36 | + And I own a sample reading group | ||
| 37 | + And I am at the All Reading Groups page | ||
| 38 | + When I click the Edit link | ||
| 39 | + Then The field "reading_group[name]" should be filled with the sample reading group "name" | ||
| 40 | + And The field "reading_group[description]" should be filled with the sample reading group "description" | ||
| 41 | + | ||
| 42 | + @kalibro_restart | ||
| 43 | + Scenario: With valid attributes | ||
| 44 | + Given I am a regular user | ||
| 45 | + And I am signed in | ||
| 46 | + And I own a sample reading group | ||
| 47 | + And I am at the sample reading group edit page | ||
| 48 | + And I fill the Name field with "My Reading Group" | ||
| 49 | + And I fill the Description field with "New Reading Group" | ||
| 50 | + When I press the Save button | ||
| 51 | + Then I should see "My Reading Group" | ||
| 52 | + And I should see "New Reading Group" | ||
| 53 | + | ||
| 54 | + @kalibro_restart | ||
| 55 | + Scenario: With reading group name already taken | ||
| 56 | + Given I am a regular user | ||
| 57 | + And I am signed in | ||
| 58 | + And I have a reading group named "A Reading" | ||
| 59 | + And I own a reading group named "My reading" | ||
| 60 | + And I am at the sample reading group edit page | ||
| 61 | + And I fill the Name field with "A Reading" | ||
| 62 | + When I press the Save button | ||
| 63 | + Then I should see "There's already" | ||
| 64 | + | ||
| 65 | + @kalibro_restart | ||
| 66 | + Scenario: Editing just the description | ||
| 67 | + Given I am a regular user | ||
| 68 | + And I am signed in | ||
| 69 | + And I own a sample reading group | ||
| 70 | + And I am at the sample reading group edit page | ||
| 71 | + And I fill the Description field with "New Reading Group" | ||
| 72 | + When I press the Save button | ||
| 73 | + Then I should see "New Reading Group" | ||
| 74 | + | ||
| 75 | + @kalibro_restart | ||
| 76 | + Scenario: With blank reading group name | ||
| 77 | + Given I am a regular user | ||
| 78 | + And I am signed in | ||
| 79 | + And I own a sample reading group | ||
| 80 | + And I am at the sample reading group edit page | ||
| 81 | + And I fill the Name field with " " | ||
| 82 | + When I press the Save button | ||
| 83 | + Then I should see "Name can't be blank" |
features/step_definitions/reading_group_steps.rb
| @@ -25,6 +25,23 @@ Given(/^I visit the Sample Reading Group page$/) do | @@ -25,6 +25,23 @@ Given(/^I visit the Sample Reading Group page$/) do | ||
| 25 | visit reading_group_path(@reading_group.id) | 25 | visit reading_group_path(@reading_group.id) |
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | +Given(/^I am at the sample reading group edit page$/) do | ||
| 29 | + visit edit_reading_group_path(@reading_group.id) | ||
| 30 | +end | ||
| 31 | + | ||
| 32 | +Given(/^I own a reading group named "(.*?)"$/) do |name| | ||
| 33 | + @reading_group = FactoryGirl.create(:reading_group, {id: nil, name: name}) | ||
| 34 | + FactoryGirl.create(:reading_group_ownership, {user_id: @user.id, reading_group_id: @reading_group.id}) | ||
| 35 | +end | ||
| 36 | + | ||
| 37 | +When(/^I visit the sample reading group edit page$/) do | ||
| 38 | + visit edit_reading_group_path(@reading_group.id) | ||
| 39 | +end | ||
| 40 | + | ||
| 41 | +Then(/^The field "(.*?)" should be filled with the sample reading group "(.*?)"$/) do |field, value| | ||
| 42 | + page.find_field(field).value.should eq(@reading_group.send(value)) | ||
| 43 | +end | ||
| 44 | + | ||
| 28 | Then(/^I should be in the Sample Reading Group page$/) do | 45 | Then(/^I should be in the Sample Reading Group page$/) do |
| 29 | page.should have_content(@reading_group.name) | 46 | page.should have_content(@reading_group.name) |
| 30 | page.should have_content(@reading_group.description) | 47 | page.should have_content(@reading_group.description) |
| @@ -37,4 +54,8 @@ Then(/^I should see the information of the sample reading$/) do | @@ -37,4 +54,8 @@ Then(/^I should see the information of the sample reading$/) do | ||
| 37 | color = @reading.color.downcase | 54 | color = @reading.color.downcase |
| 38 | var = (pager =~ /#{color}/) | 55 | var = (pager =~ /#{color}/) |
| 39 | var.should_not be_nil | 56 | var.should_not be_nil |
| 57 | +end | ||
| 58 | + | ||
| 59 | +Then(/^I should be in the Edit Reading Group page$/) do | ||
| 60 | + visit edit_reading_group_path(@reading_group.id) | ||
| 40 | end | 61 | end |
| 41 | \ No newline at end of file | 62 | \ No newline at end of file |