Commit 478ef5e4e35a0f7fa11bcdbd6d4e682c8bdae1ae
Committed by
Rafael Manzo
1 parent
7fa4bdd8
Exists in
colab
and in
4 other branches
Edit view for reading group
Unfinished acceptance test Signed-off By: Fellipe Souto Sampaio <fllsouto@gmail.com> Signed-off By: Guilherme Rojas V. de Lima <guilhermehrojas@gmail.com> Signed-off By: Diego Araújo <diegoamc90@gmail.com>
Showing
3 changed files
with
39 additions
and
17 deletions
Show diff stats
app/views/reading_groups/show.html.erb
... | ... | @@ -11,22 +11,21 @@ |
11 | 11 | |
12 | 12 | <h2>Readings</h2> |
13 | 13 | |
14 | -<% if reading_group_owner? @reading_group.id %><%= link_to 'New Reading', new_reading_group_reading_path(@reading_group,), class: 'btn btn-primary' %><% end %> | |
14 | +<% if reading_groups_owner? @reading_group.id %><%= link_to 'New Reading', new_reading_group_reading_path(@reading_group,), class: 'btn btn-primary' %><% end %> | |
15 | 15 | |
16 | 16 | <table class="table table-hover"> |
17 | 17 | <thead> |
18 | 18 | <tr> |
19 | - <th>Name</th> | |
20 | - <th>Type</th> | |
21 | - <th>Address</th> | |
22 | - <th colspan="2"></th> | |
19 | + <th>Label</th> | |
20 | + <th>Grade</th> | |
21 | + <th>Color</th> | |
23 | 22 | </tr> |
24 | 23 | </thead> |
25 | 24 | |
26 | 25 | <tbody> |
27 | 26 | <% if @reading_group_readings.size == 0 %> |
28 | 27 | <tr> |
29 | - <% col_number = reading_group_owner?(@reading_group.id) ? 4 : 3 %> | |
28 | + <% col_number = reading_groups_owner?(@reading_group.id) ? 5 : 3 %> | |
30 | 29 | <td colspan="<%= col_number %>">There are no readings yet!</td> |
31 | 30 | </tr> |
32 | 31 | <% end %> |
... | ... | @@ -34,15 +33,16 @@ |
34 | 33 | <tr> |
35 | 34 | <td><%= reading.label %></td> |
36 | 35 | <td><%= reading.grade %></td> |
37 | - <td><%= reading.color %></td> | |
38 | - <td> | |
39 | - <% if reading_group_owner? @reading_group.id %> | |
40 | - <%= link_to 'Edit', edit_project_repository_path(@project, repository.id), class: 'btn btn-info' %> | |
41 | - <% end %> | |
42 | - </td> | |
43 | - <td> | |
44 | - <%= link_to 'Show', project_repository_path(@project, repository.id), class: 'btn btn-info' %></td> | |
45 | - </td> | |
36 | + <td style="background-color: #<%= reading.color %>; width: 20%;"> </td> | |
37 | + <% if reading_groups_owner? @reading_group.id %> | |
38 | + <td> | |
39 | + <%= link_to 'Edit', edit_reading_group_reading_path(@reading_group.id, reading.id), class: 'btn btn-info' %> | |
40 | + </td> | |
41 | + <td> | |
42 | + <%= link_to 'Destroy', reading_group_reading_path(@reading_group.id, reading.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this reading?' }, class: 'btn btn-danger' %> | |
43 | + </td> | |
44 | + </td> | |
45 | + <% end %> | |
46 | 46 | </tr> |
47 | 47 | <% end %> |
48 | 48 | </tbody> |
... | ... | @@ -51,7 +51,7 @@ |
51 | 51 | <hr /> |
52 | 52 | |
53 | 53 | <p> |
54 | - <% if project_owner? @project.id %> | |
55 | - <%= link_to 'Destroy project', project_path(@project.id), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %> | |
54 | + <% if reading_groups_owner? @reading_group.id %> | |
55 | + <%= link_to 'Destroy reading group', reading_group_path(@reading_group.id), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %> | |
56 | 56 | <% end %> |
57 | 57 | </p> | ... | ... |
features/reading_group/show.feature
... | ... | @@ -12,3 +12,15 @@ Scenario: Should not show the create reading link to user that doesn't own the r |
12 | 12 | Then I should not see New Reading |
13 | 13 | And I should not see Destroy reading group |
14 | 14 | And I should not see Edit |
15 | + | |
16 | +@kalibro_restart @wip | |
17 | +Scenario: Should show the create reading link to user that do own the reading group | |
18 | + Given I am a regular user | |
19 | + And I own a sample reading group | |
20 | + And I have a sample reading within the sample reading group | |
21 | + When I visit the Sample Reading Group page | |
22 | + Then I should be in the Sample Reading Group page | |
23 | + And I should see "Destroy" | |
24 | + And I should see "Edit" | |
25 | + And I should see "Destroy reading group" | |
26 | + And I should see "New reading group" | |
15 | 27 | \ No newline at end of file | ... | ... |
features/step_definitions/reading_group_steps.rb
... | ... | @@ -9,7 +9,17 @@ Given(/^I have a sample reading group$/) do |
9 | 9 | @reading_group = FactoryGirl.create(:reading_group, {id: nil}) |
10 | 10 | end |
11 | 11 | |
12 | +Given(/^I visit the Sample Reading Group page$/) do | |
13 | + visit reading_group_path(@reading_group.id) | |
14 | +end | |
15 | + | |
12 | 16 | When(/^I am at the Sample Reading Group page$/) do |
17 | + p @reading_group | |
13 | 18 | page.should have_content(@reading_group.name) |
14 | 19 | page.should have_content(@reading_group.description) |
15 | 20 | end |
21 | + | |
22 | +Then(/^I should be in the Sample Reading Group page$/) do | |
23 | + page.should have_content(@reading_group.name) | |
24 | + page.should have_content(@reading_group.description) | |
25 | +end | |
16 | 26 | \ No newline at end of file | ... | ... |