forked from turingschool-examples/viewing_party_lite_7
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from aevans27/new-viewing-party-page
New Viewing party page first - will add more tests after dashboard is done
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |