Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Viewing party page first - will add more tests after dashboard is done #9

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<html>
<head>
<title>ViewingPartyLite7</title>
<%= link_to "Go to Landing Page", root_path, class: 'btn btn-primary' %>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
Expand Down
15 changes: 15 additions & 0 deletions app/views/viewing_parties/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h1><%= @movie[:title] %></h1>

<%= form_with url: "/users/#{@user.id}/movies/#{@movie[:id]}/viewing-party/create", method: :post, local: true do |form| %>
<%= form.number_field :duration, value: @movie[:runtime], min: @movie[:runtime] %>
<%= form.label "Duration of Party in minutes" %>
<%= form.date_field :date, data: {provide: "datepicker"} %>
<%= form.label :date, "Date of Party" %>
<%= form.time_field :start_time %>
<%= form.label :start_time, "Start of Party" %>
<%= form.hidden_field :status, value: "host" %>
<% @users.each do |user| %>
<p><%= check_box_tag(user.id, hidden_field: :status, value: "attending #{user.id}") %> <%= form.label "#{user.id}", "#{user.name} (#{user.email})" %></p>
<% end %><br>
<%= form.submit "Create Party" %>
<% end%>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
end

get "/users/:user_id/movies/:movid_id/viewing-party/new", to: "viewing_parties#new"
post "/users/:user_id/movies/:movid_id/viewing-party/create", to: "viewing_parties#create"
end
2 changes: 1 addition & 1 deletion spec/features/users/movies/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
to_return(status: 200, body: reviews_response, headers: {})

visit "/users/#{@user1.id}/movies/268"
click_link "Go to Landing Page"
click_link "Go back to Landing Page"
expect(current_path).to eq("/")

visit "/users/#{@user1.id}/movies/268"
Expand Down
43 changes: 43 additions & 0 deletions spec/features/users/movies/viewing-party/new_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'rails_helper'

RSpec.describe 'New Viewing Party Page' do
before(:each) do
load_test_data
end

it 'When I visit the new viewing party page it contains movie title, duration of party, when date, start time, checkboxes next to each user' do
specific_movie_response = File.read('spec/fixtures/specific_movie.json')
stub_request(:get, "https://api.themoviedb.org/3/movie/268?api_key=#{Rails.application.credentials.tmdb[:key]}").
with(
headers: {
'Accept'=>'*/*',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'User-Agent'=>'Faraday v2.7.12'
}).
to_return(status: 200, body: specific_movie_response, headers: {})

visit "/users/#{@user1.id}/movies/268/viewing-party/new"
expect(page).to have_field(:duration, with:126)
expect(page).to have_field(:date)
expect(page).to have_field(:start_time)
expect(page).to have_button('Create Party')
expect(page).to have_content('Batman')

expect(@user2.user_parties.count).to eq(3)
expect(@user3.user_parties.count).to eq(2)

fill_in :duration, with: 180
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'

expect(current_path).to eq(user_path(@user1.id))
# save_and_open_page
# expect(page).to have_content('Batman')

# expect(@user2.user_parties.count).to eq(4)
# expect(@user3.user_parties.count).to eq(3)
end
end