Commit 8e81a7b643e61bdcbec2fa916adf7bc31ebfa55e

Authored by Renan Fichberg
Committed by Rafael Manzo
1 parent 09d282ff

Finished Edit Reading Group View & AcceptanceTests

Signed-of By: Fellipe Souto Sampaio <fllsouto@gmail.com>
app/views/reading_groups/edit.html.erb
... ... @@ -0,0 +1,7 @@
  1 +<div class="page-header">
  2 + <h1>Edit Reading Group</h1>
  3 +</div>
  4 +
  5 +<%= render 'form' %>
  6 +
  7 +<%= link_to 'Back', reading_group_path %>
... ...
app/views/shared/_reading_groups_list.erb
... ... @@ -9,7 +9,6 @@
9 9  
10 10 <tbody>
11 11 <% reading_groups.each do |reading_group| %>
12   - <% p reading_group %>
13 12 <tr>
14 13 <td><%= reading_group.name %></td>
15 14 <td><%= reading_group.description %></td>
... ...
features/project/edition.feature
... ... @@ -3,7 +3,7 @@ Feature: Project
3 3 As a regular user
4 4 I should be able to edit my projects
5 5  
6   - @kalibro_restart
  6 + @kalibro_restarts
7 7 Scenario: Should go to the edit page from a project that I own
8 8 Given I am a regular user
9 9 And I am signed in
... ...
features/reading_group/create.feature 0 → 100644
... ... @@ -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 44 \ No newline at end of file
... ...
features/reading_group/edit.feature 0 → 100644
... ... @@ -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 25 visit reading_group_path(@reading_group.id)
26 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 45 Then(/^I should be in the Sample Reading Group page$/) do
29 46 page.should have_content(@reading_group.name)
30 47 page.should have_content(@reading_group.description)
... ... @@ -37,4 +54,8 @@ Then(/^I should see the information of the sample reading$/) do
37 54 color = @reading.color.downcase
38 55 var = (pager =~ /#{color}/)
39 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 61 end
41 62 \ No newline at end of file
... ...