Skip to content

Commit

Permalink
adds failing test for #create for student profiles controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ric9176 committed Apr 7, 2016
1 parent e79214f commit 8b7e667
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/student_profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def save_profile_and_redirect
@profile = StudentProfile.create(profile_params)
current_student.student_profile = @profile
if @profile.save
redirect_to student_profile_path(:id => current_student.id)
redirect_to student_profile_path(id: current_student.id)
else
render 'new'
end
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/student_profiles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
expect(response).to render_template("new")
end
end

describe 'POST create' do
it 'creates and saves a new profile' do
current_student = create(:student)
expect{
post :create, student_profile: FactoryGirl.attributes_for(:student_profile)
}.to change(StudentProfile,:count).by(1)
end
end
end


Expand Down
2 changes: 2 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.include FactoryGirl::Syntax::Methods
config.include Devise::TestHelpers, :type => :controller



config.use_transactional_fixtures = false
Expand Down

0 comments on commit 8b7e667

Please sign in to comment.