Commit 153d6ef6fb093437f6e62b729570d8219297194a

Authored by Diego Camarinha
Committed by Rafael Manzo
1 parent 946d9a21

ReadingGroup acceptance tests working.

Signed off by: Daniel Alves <danpaulalves@gmail.com>
app/controllers/reading_groups_controller.rb
@@ -35,7 +35,7 @@ class ReadingGroupsController &lt; ApplicationController @@ -35,7 +35,7 @@ class ReadingGroupsController &lt; ApplicationController
35 def edit; end 35 def edit; end
36 36
37 def update 37 def update
38 - if @reading_group.save(reading_group_params) 38 + if @reading_group.update(reading_group_params)
39 redirect_to(reading_group_path(@reading_group.id)) 39 redirect_to(reading_group_path(@reading_group.id))
40 else 40 else
41 render "edit" 41 render "edit"
@@ -74,7 +74,7 @@ class ReadingGroupsController &lt; ApplicationController @@ -74,7 +74,7 @@ class ReadingGroupsController &lt; ApplicationController
74 format.json { render action: 'show', status: :created, location: @reading_group } 74 format.json { render action: 'show', status: :created, location: @reading_group }
75 else 75 else
76 format.html { render action: 'new' } 76 format.html { render action: 'new' }
77 - format.json { render json: @reading_group.errors, status: :unprocessable_entity } 77 + format.json { render json: @reading_group.kalibro_errors, status: :unprocessable_entity }
78 end 78 end
79 end 79 end
80 end 80 end
app/models/reading_group.rb
1 class ReadingGroup < KalibroClient::Entities::Configurations::ReadingGroup 1 class ReadingGroup < KalibroClient::Entities::Configurations::ReadingGroup
  2 + include KalibroRecord
2 end 3 end
features/reading_group/create.feature
@@ -30,7 +30,7 @@ Scenario: reading group creation with already taken name @@ -30,7 +30,7 @@ Scenario: reading group creation with already taken name
30 And I fill the Name field with "Group" 30 And I fill the Name field with "Group"
31 And I fill the Description field with "Same Group" 31 And I fill the Description field with "Same Group"
32 When I press the Save button 32 When I press the Save button
33 - Then I should see "Name There is already a ReadingGroup with name Group!" 33 + Then I should see "Name has already been taken"
34 34
35 @kalibro_configuration_restart 35 @kalibro_configuration_restart
36 Scenario: reading group creation with blank name 36 Scenario: reading group creation with blank name
features/reading_group/edit.feature
@@ -60,7 +60,7 @@ Feature: Reading Group @@ -60,7 +60,7 @@ Feature: Reading Group
60 And I am at the sample reading group edit page 60 And I am at the sample reading group edit page
61 And I fill the Name field with "A Reading" 61 And I fill the Name field with "A Reading"
62 When I press the Save button 62 When I press the Save button
63 - Then I should see "Name There is already a ReadingGroup with name A Reading!" 63 + Then I should see "Name has already been taken"
64 64
65 @kalibro_configuration_restart 65 @kalibro_configuration_restart
66 Scenario: Editing just the description 66 Scenario: Editing just the description
features/step_definitions/reading_group_steps.rb
@@ -55,7 +55,7 @@ Then(/^I should see the information of the sample reading$/) do @@ -55,7 +55,7 @@ Then(/^I should see the information of the sample reading$/) do
55 expect(page).to have_content(@reading.label) 55 expect(page).to have_content(@reading.label)
56 expect(page).to have_content(@reading.grade) 56 expect(page).to have_content(@reading.grade)
57 pager = page.body 57 pager = page.body
58 - color = @reading.color.downcase 58 + color = @reading.color
59 var = (pager =~ /#{color}/) 59 var = (pager =~ /#{color}/)
60 expect(var).to_not be_nil 60 expect(var).to_not be_nil
61 end 61 end
spec/controllers/reading_groups_controller_spec.rb
@@ -211,7 +211,7 @@ describe ReadingGroupsController, :type =&gt; :controller do @@ -211,7 +211,7 @@ describe ReadingGroupsController, :type =&gt; :controller do
211 context 'with valid fields' do 211 context 'with valid fields' do
212 before :each do 212 before :each do
213 subject.expects(:find_resource).with(ReadingGroup, @subject.id).returns(@subject) 213 subject.expects(:find_resource).with(ReadingGroup, @subject.id).returns(@subject)
214 - ReadingGroup.any_instance.expects(:save).with(@subject_params).returns(true) 214 + ReadingGroup.any_instance.expects(:update).with(@subject_params).returns(true)
215 end 215 end
216 216
217 context 'rendering the show' do 217 context 'rendering the show' do
@@ -236,7 +236,7 @@ describe ReadingGroupsController, :type =&gt; :controller do @@ -236,7 +236,7 @@ describe ReadingGroupsController, :type =&gt; :controller do
236 context 'with an invalid field' do 236 context 'with an invalid field' do
237 before :each do 237 before :each do
238 subject.expects(:find_resource).with(ReadingGroup, @subject.id).returns(@subject) 238 subject.expects(:find_resource).with(ReadingGroup, @subject.id).returns(@subject)
239 - ReadingGroup.any_instance.expects(:save).with(@subject_params).returns(false) 239 + ReadingGroup.any_instance.expects(:update).with(@subject_params).returns(false)
240 240
241 post :update, :id => @subject.id, :reading_group => @subject_params 241 post :update, :id => @subject.id, :reading_group => @subject_params
242 end 242 end