Skip to content

Commit

Permalink
Merge pull request #9 from aevans27/new-viewing-party-page
Browse files Browse the repository at this point in the history
New Viewing party page first - will add more tests after dashboard is done
  • Loading branch information
bkchilidawg authored Nov 30, 2023
2 parents 0ae8e9d + cf5d5a7 commit 8407327
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
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
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

0 comments on commit 8407327

Please sign in to comment.