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

Registration sad path #126

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d6af67e
Create pull_request_template.md
LawrenceWhalen Jul 5, 2021
62f0b55
Update pull_request_template.md
LawrenceWhalen Jul 5, 2021
3823fa2
Add refactor option to change type
LawrenceWhalen Jul 5, 2021
709d03f
Add heroku data to travis CI
LawrenceWhalen Jul 5, 2021
b72daab
Start Travis
LawrenceWhalen Jul 6, 2021
85e39b8
Update .travis.yml
LawrenceWhalen Jul 6, 2021
a24541d
Update pull_request_template.md
LawrenceWhalen Jul 6, 2021
4e74e33
Merge pull request #1 from LawrenceWhalen/Whalen-pull-request-template
LawrenceWhalen Jul 6, 2021
d57349f
Create model tests and models
LawrenceWhalen Jul 6, 2021
1b42293
Create and test self reference for user
LawrenceWhalen Jul 6, 2021
5a03b14
Early push for emergency
LawrenceWhalen Jul 6, 2021
8da2503
fix migration of atendee
Aphilosopher30 Jul 6, 2021
8d9ff53
make tests for models relationships
Aphilosopher30 Jul 6, 2021
a1e9724
Merge branch 'main' of github.com:LawrenceWhalen/viewing_party
LawrenceWhalen Jul 7, 2021
df83cf3
Merge branch 'main' into model-test
LawrenceWhalen Jul 7, 2021
fb39cbf
Update gemfile ruby version
LawrenceWhalen Jul 7, 2021
bb766fe
Create and test the user creation process
LawrenceWhalen Jul 7, 2021
6809c32
Merge branch 'main' into creation-setup
LawrenceWhalen Jul 7, 2021
0860123
Merge pull request #22 from LawrenceWhalen/model-test
Aphilosopher30 Jul 7, 2021
dbbef03
Update user_spec.rb
LawrenceWhalen Jul 7, 2021
6a5d5e6
Merge branch 'main' into creation-setup
LawrenceWhalen Jul 7, 2021
bddb74d
Merge branch 'main' of github.com:LawrenceWhalen/viewing_party
LawrenceWhalen Jul 7, 2021
eaff82e
Delete 20210707213534_create_attendee.rb
LawrenceWhalen Jul 7, 2021
0ca8ad5
Merge pull request #23 from LawrenceWhalen/creation-setup
Aphilosopher30 Jul 7, 2021
7ff5771
Merge branch 'main' of github.com:LawrenceWhalen/viewing_party
LawrenceWhalen Jul 7, 2021
c07ddb5
Test and create loggin in and out
LawrenceWhalen Jul 7, 2021
7789ccc
Merge pull request #24 from LawrenceWhalen/login-setup
Aphilosopher30 Jul 8, 2021
24e3531
sad paths for registration
Aphilosopher30 Jul 8, 2021
ca48956
Swap from sessions to cookies and show path to dashboard
LawrenceWhalen Jul 8, 2021
2305e40
upgrade ruby version
Aphilosopher30 Jul 8, 2021
0ccc36d
preperation for murge to main
Aphilosopher30 Jul 8, 2021
b35b3cc
add tests to check that we are adding what we want to the data base
Aphilosopher30 Jul 8, 2021
36ba12a
Setup webmock/vcr and write tests for api
LawrenceWhalen Jul 8, 2021
718af8e
add password confirmation
Aphilosopher30 Jul 8, 2021
120fae6
validate features
Aphilosopher30 Jul 8, 2021
13e8e91
Create test for and pass movie index tests
LawrenceWhalen Jul 8, 2021
4183917
Remove sensative data
LawrenceWhalen Jul 8, 2021
a825363
Merge pull request #26 from LawrenceWhalen/movies-setup
Aphilosopher30 Jul 9, 2021
4152ac4
merge changes into branch
Aphilosopher30 Jul 9, 2021
b823a73
validation tests fix
Aphilosopher30 Jul 9, 2021
d100dcd
Sensitive data
LawrenceWhalen Jul 9, 2021
66fdf56
Sensitive data
LawrenceWhalen Jul 9, 2021
a116193
Sensitive data
LawrenceWhalen Jul 9, 2021
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
Prev Previous commit
Next Next commit
Setup webmock/vcr and write tests for api
LawrenceWhalen committed Jul 8, 2021
commit 36ba12a0ba48e6074ec67367b5372ce2c585187c
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -12,5 +12,5 @@ deploy:
api_key:
secure: LUNR1EsF3qm7rOxPk8pqu9lltrphHB54ViLuuYu6nRnpYa4ef/9WDBklqzAyR2sQynDoUnqNufkF2HhJjP0BWfH/c8fDYhD7D37+9LrRo0ugwOjOAbQkrm4x36DxKbXHHDbiThiP5is+VMw3iQZu5DOPIup+uF1RXU0db7/XsfIlXtuCiBKqKTvhZYgDZvRL5GxxP3yu7YZaRf2un4a+L23iWPUWZi+CI4Aq6gxuTCkOfmGTSsFEaVdgDvNQU0EBag0wxkrHIJRREcngDrJPMOxwo0zP0Ta28k19QplFADgV/dBi3/E/scPQ+B0b04kWpGVymgaZo5wv4X86vpB4bYoiyiVtDHj4qr4ndHiMw01rprPkzVtj02HX1r7ko972NB3MXykyGzC3PZttcb0p5z5Jbm+2MhmVrBBegIXG+uSABkRxSq9KHvUc1jOzQCU6lfPj0BcBZFJB/ku7m6i7P2CAlOuvCY5F+NVYnD48mK7hepf9hKP+XSzrxRBii229oD5S+cW6EUqwOzN/mofNWxKWNHglJao+/BNqVxsXLjZRgUFH2sZQzstuzTegwjA25NobGxmq8FwRHf6kP93uif9lSd7fJjETqQ2vr7ntAJAf6bgyA+1x19Y9ccfE8JV1yhPSOq+6zh6lA4Vdr4x7/Qto6efO2+pOEkn3QJMSyng=

app: https://viewing-party-turing.herokuapp.com/
app: viewing-party-turing
run: rails db:migrate
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -38,6 +38,8 @@ group :test do
gem 'factory_bot_rails', '~> 4.0'
gem 'shoulda-matchers'
gem 'database_cleaner'
gem 'webmock'
gem 'vcr'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -70,6 +70,8 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.8)
crack (0.4.5)
rexml
crass (1.0.6)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
@@ -111,6 +113,7 @@ GEM
net-http-pipeline
globalid (0.4.2)
activesupport (>= 4.2.0)
hashdiff (1.0.1)
highline (2.0.3)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
@@ -293,11 +296,16 @@ GEM
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.0.0)
vcr (6.0.0)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webmock (3.13.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket (1.2.9)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
@@ -338,7 +346,9 @@ DEPENDENCIES
travis
tzinfo-data
uglifier (>= 1.3.0)
vcr
web-console (>= 3.3.0)
webmock

RUBY VERSION
ruby 2.7.2p137
28 changes: 28 additions & 0 deletions app/services/imdb_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class ImdbService
def self.top_movies_search(search)
search_terms = search.gsub(' ', '+')
response_1 = Faraday.get "https://api.themoviedb.org/3/search/movie?api_key=e1dce8b90f48a3084940ca941868f474&query=#{search_terms}&page=1"
response_2 = Faraday.get "https://api.themoviedb.org/3/search/movie?api_key=e1dce8b90f48a3084940ca941868f474&query=#{search_terms}&page=2"
body_1 = response_1.body
body_2 = response_2.body
ruby_body_1 = JSON.parse(body_1, symbolize_names: true)
ruby_body_2 = JSON.parse(body_2, symbolize_names: true)
ruby_body = ruby_body_1[:results].concat(ruby_body_2[:results])
return 'No Movies Found' if ruby_body == []
ruby_body.each_with_object([]) do |movie, array|
array.push({title: movie[:title], vote: [:vote_average]})
end
end
def self.top_movies
response_1 = Faraday.get "https://api.themoviedb.org/3/discover/movie?sort_by=popularity.desc&api_key=e1dce8b90f48a3084940ca941868f474&page=1"
response_2 = Faraday.get "https://api.themoviedb.org/3/discover/movie?sort_by=popularity.desc&api_key=e1dce8b90f48a3084940ca941868f474&page=2"
body_1 = response_1.body
body_2 = response_2.body
ruby_body_1 = JSON.parse(body_1, symbolize_names: true)
ruby_body_2 = JSON.parse(body_2, symbolize_names: true)
ruby_body = ruby_body_1[:results].concat(ruby_body_2[:results])
ruby_body.each_with_object([]) do |movie, array|
array.push({title: movie[:title], vote: [:vote_average]})
end
end
end
1 change: 1 addition & 0 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%= "Welcome #{@user.email}" %>

<%= link_to "Discover Movies", '/discover' %>
<%= link_to "Log out", '/logout', method: :delete %>
3 changes: 2 additions & 1 deletion app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<h1>Welcome</h1>
<h2>This app will help you find movies and invite your friends to watch them with you!</h2>

<% if current_user %>
<%= link_to "Log out", '/logout', method: :delete %>
<% else %>
<%= link_to "Register New Account", "/register" %>
<%= link_to "Register New Account", "/register" %><p>
<%= link_to "I already have an Account", "/login" %>
<% end %>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -8,5 +8,6 @@
post '/login', to:'sessions#create'
delete '/logout', to: 'sessions#destroy'
get '/dashboard', to: 'users#show'
get '/discover', to: 'discover#index'

end
105 changes: 105 additions & 0 deletions spec/cassettes/imdb_nil.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions spec/cassettes/imdb_search.yml

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions spec/cassettes/imdb_top.yml

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions spec/features/movie_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
require 'rails_helper'

RSpec.describe 'Movies Page' do
let(:user) { create(:user) }
stub_request(:any, 'https://api.themoviedb.org').
to_return(:body => %Q(
{
title: "Jack Reacher",
vote_average: 6.5
},
{
title: "Jack be Nimble",
vote_average: 5.0
}
))
# cookies.encrypted[:user_id] = user.id
describe 'location' do
it 'can be reached from the dashboard' do
VCR.use_cassette 'imdb_top' do

visit '/dashboard'

expect(page).to have_link('Discover Movies')

click_on 'Discover Movies'

expect(page).to have_current_path('/discover')
expect(page).to have_button('Discover top 40 movies')

click_on 'Discover top 40 movies'
require 'pry', binding.pry

expect(page).to have_current_path('/movies')
expect(page).to have_content('Luca')
end
end
end
describe 'Searching for a movie' do
it 'returns a list of movies' do
visit '/discover'

fill_in :movie_title, with: 'Jack'
click_on 'Find Top Rated Movies'

expect(page)
expect(page).to have_field('search_title')

expect(page).to have_current_path('/movies')
expect(page).to have_link('Jack Ryan')
expect(page).to have_content('6.5')
expect(page).to have_link('Jack be Nimble')
expect(page).to have_content('5.0')

click_on 'Jack Ryan'

expect(page).to have_current_path('/movies/details')
end
end
end
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }

# Checks for pending migrations and applies them before tests are run.
# If you are not using ActiveRecord, you can remove these lines.
39 changes: 39 additions & 0 deletions spec/services/imbd_service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'rails_helper'

RSpec.describe ImdbService do
describe 'class methods' do
describe '.top_movies_search' do
it 'returns an array based on search' do
VCR.use_cassette 'imdb_search' do
actual = ImdbService.top_movies_search('Jack')

expect(actual.class).to eq(Array)
expect(actual[0][:title].include?('Jack')).to eq(true)
expect(actual[0][:title].nil?).to eq(false)
expect(actual[0].class).to eq(Hash)
expect(actual.count).to eq(40)
end
end
it 'returns No Movies Found if not title matches' do
VCR.use_cassette 'imdb_nil' do
actual = ImdbService.top_movies_search('klsdjfl')

expect(actual).to eq('No Movies Found')
end
end
end
describe '.top_movies' do
it 'returns an array containing the top movies titles and vote average' do
VCR.use_cassette 'imdb_top' do
actual = ImdbService.top_movies

expect(actual.class).to eq(Array)
expect(actual[0][:title].include?('Luca')).to eq(true)
expect(actual[0][:title].nil?).to eq(false)
expect(actual[0].class).to eq(Hash)
expect(actual.count).to eq(40)
end
end
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
# it.
#
require 'simplecov'
require 'webmock/rspec'
SimpleCov.start 'rails'
SimpleCov.add_filter ['spec', 'config']
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
6 changes: 6 additions & 0 deletions spec/support/vcr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
VCR.configure do |c|
c.cassette_library_dir = 'spec/cassettes'
c.hook_into :webmock
c.ignore_localhost = true
c.ignore_hosts "chromedriver.storage.googleapis.com"
end
3 changes: 3 additions & 0 deletions spec/support/webmock.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require "webmock/rspec"

WebMock.disable_net_connect!(allow_localhost: true)