diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d04f579ed..c05608522 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/spec/features/users/movies/viewing-party/new_spec.rb b/spec/features/users/movies/viewing-party/new_spec.rb index 08d631b90..c300f10c9 100644 --- a/spec/features/users/movies/viewing-party/new_spec.rb +++ b/spec/features/users/movies/viewing-party/new_spec.rb @@ -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) @@ -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' diff --git a/spec/features/users/new_spec.rb b/spec/features/users/new_spec.rb index 16d89c415..7ebeaa6bf 100644 --- a/spec/features/users/new_spec.rb +++ b/spec/features/users/new_spec.rb @@ -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 \ No newline at end of file