Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
better test coverage and removed unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
gurix committed Jun 24, 2014
1 parent ec19882 commit d471c3d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
5 changes: 0 additions & 5 deletions app/controllers/helena/admin/question_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ def create

if @question_group.save
notify_successful_create_for(@question_group.title)
else
notify_error
end
respond_with @question_group, location: admin_survey_question_groups_path(@survey)
end
Expand All @@ -37,9 +35,6 @@ def update

if @question_group.update_attributes question_group_params
notify_successful_update_for(@question_group.title)
else
notify_error
add_breadcrumb @question_group.title_was
end
respond_with @question_group, location: admin_survey_question_groups_path(@survey)
end
Expand Down
18 changes: 18 additions & 0 deletions spec/features/helena/admin/manage_question_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
expect { click_button 'Save' }.to change { question_group.reload.questions.count }.by(1)
end

scenario 'creating a new question errors when without entering a code' do
visit helena.new_admin_survey_question_group_question_path(draft_version.survey, question_group)

fill_in 'Code', with: ''

expect { click_button 'Save' }.to change { question_group.reload.questions.count }.by(0)
end

scenario 'edits a question' do
question = create :question, question_text: 'We are here?', question_group: question_group

Expand All @@ -52,6 +60,16 @@
expect(question.reload.code).to eq 'b12'
end

scenario 'edits a question errors when code text is empty' do
question = create :question, question_text: 'We are here?', question_group: question_group

visit helena.edit_admin_survey_question_group_question_path(draft_version.survey, question.question_group, question)

fill_in 'Code', with: ''

expect{ click_button 'Save' }.not_to change { question.reload }
end

scenario 'moving a question' do
first_question = create :question, question_group: question_group, position: 1
second_question = create :question, question_group: question_group, position: 2
Expand Down
7 changes: 7 additions & 0 deletions spec/features/helena/admin/manage_survey_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@
end

expect { click_button 'Save' }.to change { Helena::Survey.count }.by 1
end

scenario 'creates a new surveys errors without a name' do
visit helena.new_admin_survey_path

fill_in 'Name', with: ''

expect { click_button 'Save' }.to change { Helena::Survey.count }.by 0
end

scenario 'edits a survey' do
Expand Down

0 comments on commit d471c3d

Please sign in to comment.