Skip to content

Commit

Permalink
Merge pull request #13 from aevans27/test-checking-allan
Browse files Browse the repository at this point in the history
Add missing tests for sad paths
  • Loading branch information
bkchilidawg authored Dec 1, 2023
2 parents 331e27c + 16428a3 commit 77e18ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def create
if @user.save
redirect_to user_path(@user)
else
flash[:alert] = "Error: something is wrong with credentials"
render :new
end
end
Expand Down
5 changes: 1 addition & 4 deletions spec/features/users/movies/viewing-party/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
expect(current_path).to eq(user_path(@user1.id))
end

it 'sad path for creating a party: Empty duration' do
it 'sad path for creating a party: Bad data' do
visit "/users/#{@user1.id}/movies/268/viewing-party/new"
expect(page).to have_field(:duration, with:126)
expect(page).to have_field(:date)
Expand All @@ -67,9 +67,6 @@
expect(@user2.user_parties.count).to eq(3)
expect(@user3.user_parties.count).to eq(2)

fill_in :duration, with: ""
fill_in :start_time, with: '10:00'
fill_in :date, with: '2023/08/01'
check "#{@user2.name} (#{@user2.email})"
check "#{@user3.name} (#{@user3.email})"
click_button 'Create Party'
Expand Down
8 changes: 8 additions & 0 deletions spec/features/users/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@
user = User.find_by(email: 'john@example.com')
expect(current_path).to eq("/users/#{user.id}")
end

it 'redirects user to create user page if bad data is entered' do
visit '/register'
fill_in 'Email', with: 'john@example.com'
fill_in 'Password', with: 'Sooners!2022'
click_button 'Register'
expect(current_path).to eq("/users")
end
end

0 comments on commit 77e18ce

Please sign in to comment.