diff --git a/.gitignore b/.gitignore index e16dc71d2..96c635955 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ # Ignore master key for decrypting credentials and more. /config/master.key + + +# Ignore coverage +/coverage \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..2aca9d06e --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,6 @@ +Style/FrozenStringLiteralComment: + Enabled: false + +Metrics/BlockLength: + IgnoredMethods: + - RSpec.describe \ No newline at end of file diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb new file mode 100644 index 000000000..875912fe2 --- /dev/null +++ b/app/controllers/landing_controller.rb @@ -0,0 +1,3 @@ +class LandingController < ApplicationController + +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3927ebebf..8f4ef0502 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,25 +1,18 @@ class UsersController < ApplicationController - def new - @user = User.new - end - - def create - @user = User.new(user_params) - - if @user.save - redirect_to user_path(@user) - else - render :new - end - end + def index + @users = User.all def show @user = User.find(params[:id]) end + def new + @user = User.create(user_params) + end + private def user_params - params.require(:user).permit(:name, :email) + params.permit(:name, :email) end end diff --git a/app/views/shared/_nav.html.erb b/app/views/shared/_nav.html.erb new file mode 100644 index 000000000..e680794f6 --- /dev/null +++ b/app/views/shared/_nav.html.erb @@ -0,0 +1 @@ +<%= link_to "Viewing Party Landing Page", root_path %> \ No newline at end of file diff --git a/app/views/users/discovers/index.html.erb b/app/views/users/discovers/index.html.erb new file mode 100644 index 000000000..154edd52b --- /dev/null +++ b/app/views/users/discovers/index.html.erb @@ -0,0 +1 @@ +<%= 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 new file mode 100644 index 000000000..528da404a --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1,8 @@ +<%= render partial: "shared/nav" %> + +

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

+ +

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 9bcb46765..1a621709b 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,3 +1,5 @@ +<%= 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 %> diff --git a/config/routes.rb b/config/routes.rb index 6d9e22a96..0982296dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,15 +1,10 @@ -# frozen_string_literal: true - Rails.application.routes.draw do # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Defines the root path route ("/") # root "articles#index" - - get '/register', to: 'users#new' - post '/register', to: 'users#create' - - resources :users, only: [:index, :show] do - resources :discover, only: [:index], controller: 'users/discover' - end + 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 end diff --git a/spec/features/landing_spec.rb b/spec/features/landing_spec.rb new file mode 100644 index 000000000..6043ddb06 --- /dev/null +++ b/spec/features/landing_spec.rb @@ -0,0 +1,39 @@ +require 'rails_helper' + +RSpec.describe 'landing page', type: :feature do + # this test applies to all pages + it 'has a link to the landing page' do + visit '/' + + expect(page).to have_link('Viewing Party Landing Page') + click_link('Viewing Party Landing Page') + expect(current_path).to eq(root_path) + end + + it 'contains the name of the application' do + visit '/' + + expect(page).to have_content('Viewing Party') + end + + it 'has a button to create a new user' do + visit '/' + + expect(page).to have_button('New User') + click_button('New User') + expect(current_path).to eq('/users/new') + end + + it 'has a list of existing users' do + user_1 = User.create(name: 'Kam', email: 'kameron@turing.edu') + user_2 = User.create(name: 'Joseph', email: 'joseph@turing.edu') + + visit '/' + + expect(page).to have_content(user_1.name) + expect(page).to have_content(user_2.name) + expect(page).to have_link(user_1.name) + click_link(user_1.name) + expect(current_path).to eq("/users/#{user_1.id}") + end +end diff --git a/spec/features/user_dashboard_spec.rb b/spec/features/users/show_spec.rb similarity index 76% rename from spec/features/user_dashboard_spec.rb rename to spec/features/users/show_spec.rb index 3e43300c1..e7d4582a2 100644 --- a/spec/features/user_dashboard_spec.rb +++ b/spec/features/users/show_spec.rb @@ -1,6 +1,15 @@ require 'rails_helper' RSpec.describe 'user dashboard page', type: :feature do + # this test applies to all pages + it 'has a link to the landing page' do + visit '/' + + expect(page).to have_link('Viewing Party Landing Page') + click_link('Viewing Party Landing Page') + expect(current_path).to eq(root_path) + end + it 'lists the users name' do user = User.create(name: 'Kam', email: 'kameronk013@gmail.com')