From f519c37c8332d0a2378484af7919d8db826a620d Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 29 Nov 2023 21:34:49 -0700 Subject: [PATCH] make sure all tests pass after the merge conflict --- app/controllers/users_controller.rb | 15 +++++++++++++-- app/views/users/discover/index.html.erb | 1 + app/views/users/discovers/index.html.erb | 1 - app/views/users/index.html.erb | 5 ++++- app/views/users/show.html.erb | 2 +- config/credentials.yml.enc | 2 +- config/routes.rb | 7 ++++--- spec/features/landing_spec.rb | 2 +- spec/features/users/new_spec.rb | 3 +-- spec/features/users/show_spec.rb | 2 +- 10 files changed, 27 insertions(+), 13 deletions(-) delete mode 100644 app/views/users/discovers/index.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8f4ef0502..ef66fb804 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,18 +1,29 @@ class UsersController < ApplicationController def index @users = User.all + end def show @user = User.find(params[:id]) end def new - @user = User.create(user_params) + @user = User.new + end + + def create + @user = User.new(user_params) + + if @user.save + redirect_to user_dashboard_path(@user) + else + render :new + end end private def user_params - params.permit(:name, :email) + params.require(:user).permit(:name, :email) end end diff --git a/app/views/users/discover/index.html.erb b/app/views/users/discover/index.html.erb index e69de29bb..154edd52b 100644 --- a/app/views/users/discover/index.html.erb +++ b/app/views/users/discover/index.html.erb @@ -0,0 +1 @@ +<%= render partial: "shared/nav" %> \ No newline at end of file diff --git a/app/views/users/discovers/index.html.erb b/app/views/users/discovers/index.html.erb deleted file mode 100644 index 154edd52b..000000000 --- a/app/views/users/discovers/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render partial: "shared/nav" %> \ No newline at end of file diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 528da404a..193d3de2a 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,8 +1,11 @@ <%= render partial: "shared/nav" %> +

Viewing Party

-

<%= button_to "New User", 'users/new' %>

+

<%= button_to "New User", register_path, method: :get %>

User Index

<%@users.each do |user|%> +
    <%= link_to "#{user.name}", "users/#{user.id}"%> +
<%end%> \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 1a621709b..d3c1acecc 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,7 +1,7 @@ <%= render partial: "shared/nav" %>

<%="#{@user.name}'s Dashboard"%>

-<%= button_to "Discover Movies", user_discover_index_path(@user.id), method: :get, params: { enabled: false }, data: { turbo: false }, local: true %> +<%= button_to "Discover Movies", user_discover_path(@user.id), method: :get, params: { enabled: false }, data: { turbo: false }, local: true %>

Parties I'm Hosting

diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 010ff4b02..635a25efc 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -IdUl8TW1RuV/hrFBOw2ofbe8+xWVzpTQtF36N+5vBKyWgaq4Juryc86xLP3lLDmJ8pVNpg/g8TYSAWeu+JUTlE4iCq31IZTknkB4BPLpz4ULj3UpYkEFRSB9ZdDufx9ccU4l+4GGtdv5KRqc105s0v09MDWYT+X6NHHUrFlSGepCEXzG7JuQziJCcYxDZccsb0qlsdcUnpWspc6GBBo451lm0YviUcWx3kNsSNqApQqtQENrruynV3UoKipateylgTlrUlOMbYyHIkY1daxdV4EcxSIF1mUy6UwciNIC9xa0WnAGb+oaki6mPvs+FpWz+o548lWRrz91opxNIBv8Zrh+ZwfnQVxByuI2Uqj4fYbETjhbRfu2IbjTk1sQGqZlgougYXtMmCTxe8PNP29bmaxa2s7r4i2dAb9P--jqBTwrKsjHULkBor--z3IhADU0xjCYptFz4QGfyw== \ No newline at end of file +SxQohDKYA2r9lWQqWmurByftmF/EALpC6dTEQShJwObokj/7ool3oJW9bzj34LTRACv35C3RYDQMvcfX2QE6q88SSLCdfyiQHAd2ch01roG5N87zn1cUJc40LGBTvMogGhomBXRnKXovGAAnuqKy4nNpvCN9DXVlTMnWy42usSLOZ1Li9oPggu4wiRxhfvQXnB0RevOjbJQgDV/peQCAAA8Lspidp+IRMSyF79mEA41hpTx/VQxmldnSKExDlpgKpmtwO+F+BGOGJu2CVRWgb4eh1v3woHlnITlWKU8JwzQmyV+e5qSSeEZEb7qhm8EH+xKrW0Kn+OyudCA1qGHfgChvIC149A8ATy/d3/rMqZwvcUEwum0u/4nryLx+0Fq00vcA4roqQoGStF8wciNwU06g5+XwaoYAjDN0s3TJhoIvBlcwu3nwl/e9ywuafa1hHiPGsdNCc/cVtmRgtUIoRuRbWg==--vLv+FJCRu+mocla1--PFdQ6QmMlCPQkevBfDzbvg== \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 0982296dc..e2d6f7b2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,7 +4,8 @@ # Defines the root path route ("/") # root "articles#index" get '/', to: 'users#index', as: :root - get 'users/:id', to: 'users#show' - post '/users/new', to: 'users#new', as: :new_user_path - get '/users/:id/discover', to: 'users/discovers#index', as: :user_discover + get 'users/:id', to: 'users#show', as: :user_dashboard + get '/register', to: 'users#new' + post '/register', to: 'users#create' + get '/users/:id/discover', to: 'users/discover#index', as: :user_discover end diff --git a/spec/features/landing_spec.rb b/spec/features/landing_spec.rb index 6043ddb06..d34c2d418 100644 --- a/spec/features/landing_spec.rb +++ b/spec/features/landing_spec.rb @@ -21,7 +21,7 @@ expect(page).to have_button('New User') click_button('New User') - expect(current_path).to eq('/users/new') + expect(current_path).to eq('/register') end it 'has a list of existing users' do diff --git a/spec/features/users/new_spec.rb b/spec/features/users/new_spec.rb index 5bcf13b68..be334bba6 100644 --- a/spec/features/users/new_spec.rb +++ b/spec/features/users/new_spec.rb @@ -19,8 +19,7 @@ x = User.find_by(name: "Thomas Smith") - require 'pry'; binding.pry - expect(current_path).to eq(user_path(x.id)) + expect(current_path).to eq(user_dashboard_path(x.id)) expect(page).to have_content("Thomas Smith's Dashboard") expect(page).to have_content("Parties I'm Hosting") expect(page).to have_content("Parties I'm Invited To") diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb index e7d4582a2..a90177f36 100644 --- a/spec/features/users/show_spec.rb +++ b/spec/features/users/show_spec.rb @@ -30,6 +30,6 @@ expect(page).to have_button('Discover Movies') click_button('Discover Movies') - expect(current_path).to eq(user_discover_index_path(user.id)) + expect(current_path).to eq(user_discover_path(user.id)) end end