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

Feature specs capybara -- finishes week 3 #78

Open
wants to merge 143 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
ab0206a
Seeds Database with Videos
Feb 20, 2014
6ce4d36
Building Home Page
Feb 20, 2014
dc4d06d
Creates Home View
Feb 20, 2014
83787e6
Builds Homepage
Feb 20, 2014
938f182
Building Video Show
Feb 20, 2014
9826c9c
Building Video View
Feb 20, 2014
6bc0883
Fixing Bug in Video Show
Feb 20, 2014
4b230a7
Fixes Bug
Feb 20, 2014
920125e
Fixing Image to Match its Object
Feb 20, 2014
3ee7e5d
builds home page
Feb 21, 2014
0293c4b
Creating Category and Seeding Database
Feb 21, 2014
fbd364c
Creates Category Functionality and Improves Image to Object Programming
Feb 21, 2014
7dc0dc4
Works on Category Show view
Feb 21, 2014
decd5cd
Works on Category Show
Feb 21, 2014
100400d
Creates Videos Per Category Pages
Feb 22, 2014
89a0d05
Creates Category View For Each Category
Feb 22, 2014
f437d7a
Successfully Shows All Movies Per Category In a DRY Way
Feb 22, 2014
ce22440
DRYs up my code
Feb 22, 2014
b57bab8
tests video model's ability to save
Feb 23, 2014
52f646f
tests model associations for video and category
Feb 23, 2014
fec30df
tests for models
Feb 23, 2014
4079674
Debugs Tests in category_spec
Feb 23, 2014
019e44c
Cleans up code after kevin's code review
Feb 24, 2014
9c5436a
Uses Shoulda Matchers in Specs
Feb 25, 2014
4826a39
Refactors Preassignment Code According to TA Comments
Feb 25, 2014
92eca76
Trying to create 4 tests cases for video search method
Feb 26, 2014
75647c8
Tests Pass for Search by video's title function
Feb 26, 2014
01637c1
creates search functionality
Feb 26, 2014
41aeba2
Improves Search Functionality
Feb 26, 2014
7b37f35
Improves Search Functionality
Feb 26, 2014
abf4956
removes params[:title] from text_field_tag
Feb 27, 2014
c9b2edc
Improves tests for video to include order by time
Feb 27, 2014
deefb72
starting recent videos category method
Feb 27, 2014
52a1136
starts recent video method for category model
Feb 27, 2014
e87d7c1
works on tests for recent video method in category model
Feb 27, 2014
668172f
improves tests for search by title functionality
Feb 27, 2014
5ca8be3
removes params[:title] from text_field_tag
Feb 27, 2014
747e24b
tries to merge
Feb 27, 2014
c9231d2
adds tests for search functionality
Feb 27, 2014
79fa13c
tests video return by creation date
Feb 27, 2014
5d06e3c
refactors category tests for recent video function
Feb 27, 2014
1108dec
three passing tests
Feb 27, 2014
e6510e1
6 tests pass for recent video method
Feb 27, 2014
5055162
merges tests for recent video method
Feb 27, 2014
966b317
seeds database with varying date data
Feb 27, 2014
3cf2fe7
implements recent video method on UI
Feb 27, 2014
27a519e
works on views for sign in and log in
Feb 28, 2014
42fc5e6
working on registration form
Feb 28, 2014
b5fd250
works on registration and log in page
Mar 1, 2014
0392368
builds registration page. Must fix error validations and front-end of…
Mar 1, 2014
89bcd7e
log in form does not route to sesssions#create
Mar 1, 2014
87554b5
merges search work
Mar 1, 2014
25b4c1d
creates post route for sessions#create
Mar 1, 2014
2bb6efd
adds log_in method to session form
Mar 1, 2014
819228a
adds log_in method to session form
Mar 1, 2014
d161150
log in and registration forms and validations are working. must wire …
Mar 2, 2014
dde595d
authentication and permissions have been set up
Mar 2, 2014
960e7e8
merges works_on_landing_page_login_registration
Mar 2, 2014
3e826c7
going from red to green with controller tests and installs fabricatio…
Mar 3, 2014
115adeb
factory gem produces objects in tests
Mar 3, 2014
d76f823
installs faker gem
Mar 3, 2014
fc75e9c
installs faker gem
Mar 3, 2014
ee77df4
debugging show action in test folder for video controller
Mar 4, 2014
0fb4087
passing tests for rendering show action for setting @video variable
Mar 4, 2014
40aff54
search action tests for rendering template and setting results variab…
Mar 4, 2014
83f13ca
search action tests for rendering template and setting results variab…
Mar 4, 2014
1096bd3
refactors code after watching solution video
Mar 4, 2014
bf96cf3
user controller tests pass. trying to get sessions controller tests t…
Mar 4, 2014
9f2d8b7
user controller tests pass. trying to get sessions controller tests t…
Mar 4, 2014
b4a4b06
starts tests for sessions controller
Mar 4, 2014
c5ab843
finishes sessions controller tests, fixing failed tests in users cont…
Mar 5, 2014
4d963b1
debugs video controller and category test suites
Mar 5, 2014
54fc0d1
follows Kevin's solutions for testing user controller. however databa…
Mar 5, 2014
eb8c766
adds before boxes within context blocks
Mar 5, 2014
621d7e2
creates user and session controller test suites
Mar 5, 2014
2e176db
builds recent_reviews method for video model
Mar 6, 2014
9189c18
creates new array from video.reviews to make a collection of ratings
Mar 6, 2014
cb28606
builds #average_rating method for video model with test suite
Mar 6, 2014
ab2f038
starting to implement test suite methods from the video model on the …
Mar 6, 2014
0062fc8
implements video model methods in the UI/UX
Mar 7, 2014
aab7370
fixes layout of video show action
Mar 7, 2014
eaba0b2
setting @review variable to test that it is an instance of Review
Mar 8, 2014
c39ec54
recent video and video rating average methods are working
Mar 8, 2014
1cf529d
trying to test setup of @review instance variable
Mar 8, 2014
a5eb107
building review form
Mar 9, 2014
ca7d3a8
building form for review
Mar 10, 2014
af91cca
building review form
Mar 10, 2014
808aaf7
stuck on form for review. cannot get current user as submitted data
Mar 10, 2014
c3013c9
bug: undefined method, merge
Mar 10, 2014
d80edbb
the test, creates a review associated with the signed in user, passes
Mar 11, 2014
91d5930
review submission bug
Mar 11, 2014
3f92ef1
refactors code in reviews create action according to steve's suggestion
Mar 11, 2014
9ed6f29
debugging test for setting @video with invalid input
Mar 11, 2014
29b3dc0
trying to understand the difference between Fabricate.attriubtes_for …
Mar 11, 2014
e939cbc
test for setting @variable with invalid inputs fail
Mar 11, 2014
2432cd7
test for setting @video works for reviews controller
Mar 12, 2014
7939dcb
@reviews instance variable is set for reviews controller
Mar 12, 2014
f6f8103
sets @reviews passes
Mar 13, 2014
b77ef30
testing authorization for reviews controller
Mar 13, 2014
112cb1c
tests response for inauthenticated user and refactors reviews control…
Mar 13, 2014
fd7702b
creates index page for que
Mar 14, 2014
b523874
building add que item to my que
Mar 14, 2014
7ee79c7
refactors my code for setting @que_items and related methods
Mar 15, 2014
10a2202
adding que item to my que page
Mar 15, 2014
678a0ba
removed NaN from video show on UI/UX by adjusting Video#average_rating
Mar 15, 2014
512954c
trying to get test for creating a que_item associated with a video
Mar 16, 2014
b31aef6
trying to prevent the que from adding itself twice to someone's que
Mar 16, 2014
d627056
refactoring code from review
Mar 17, 2014
a623014
all tests pass for queue_controller and adding a queue to my quuees
Mar 17, 2014
feba281
all tests pass for queue_controller and adding a queue to my quuees
Mar 17, 2014
990b156
debugging undefined method title for nil:NilClass
Mar 17, 2014
a971b82
debugging failed tests for associating a user to a queue item
Mar 17, 2014
e571cbb
fixing a failing test, POST create redirects to the my que page
Mar 17, 2014
44dfff4
refactors code for duplicate queue item
Mar 18, 2014
990167d
all tests pass. howeverqueue_item page only contains one queue_item a…
Mar 18, 2014
e3bfab2
all tests pass. howeverqueue_item page only contains one queue_item a…
Mar 18, 2014
d72d787
executed destroy action
Mar 18, 2014
6fbc4a6
correctly executed destroy action
Mar 18, 2014
e98002a
finishes week 2 and my queue
Mar 19, 2014
3df07dd
refactors average rating code in video model
Mar 19, 2014
10f6432
refactors code based on solution for sorting queue
Mar 21, 2014
7691981
refactors code according to solutions videos for re-sorting queue_ite…
Mar 22, 2014
51b573d
cleans up reviews controller
Mar 22, 2014
f7496b1
refactors code in queue_items controller to move logic down to privat…
Mar 23, 2014
54e0375
refactors code in queue_items controller to move logic down to privat…
Mar 23, 2014
e76b541
refactors code in queue_items controller to move logic down to privat…
Mar 23, 2014
b36ce76
tries to set review rating on the queue items index view pate
Mar 23, 2014
d0624ab
tests for review virtual attributes in queue item model are failing
Mar 24, 2014
f790631
tests for review virtual attributes in queue item model are failing
Mar 24, 2014
a3540a9
enables user to change review's rating on queue items index page
Mar 25, 2014
3a0ed50
refactors tests to include video object for POST sort action
Mar 25, 2014
9f992ac
refactors code in queue_items_controller_spec, implements delegate sy…
Mar 26, 2014
fe25db0
refactors some code in reviews and queue_items controller with macros…
Mar 26, 2014
affa3a7
finishes implementation of macros and shared examples
Mar 27, 2014
420670c
creates a private method that memoizes ivar in queue_item model
Mar 27, 2014
6c6d337
starts first feature spec for signing in a users
Mar 27, 2014
2b5d52b
resolves gem file errors by installing nokogiri
Mar 27, 2014
97af8fb
builds user instance method to block add queue button if already adde…
Mar 29, 2014
da09ac0
refactors code in feature spec for re-shuffling queue and finishes we…
Mar 30, 2014
ae62be2
refactors code in feature spec for re-shuffling queue and finishes we…
Mar 30, 2014
801739b
fixes spec in queue items controller for creating a queue item that i…
Mar 30, 2014
39e41f8
finishes week 3
Mar 31, 2014
ad6e08c
refactors code according to luke's suggestions on github, changes let…
Apr 1, 2014
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: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
21 changes: 18 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ ruby '2.0.0'

gem 'bootstrap-sass'
gem 'coffee-rails'
gem 'rails'
gem 'rails', '~> 4.0.4'
gem 'haml-rails'
gem 'sass-rails'
gem 'sass-rails', '~> 4.0.2'
gem 'uglifier'
gem 'jquery-rails'
gem "bcrypt-ruby"
gem 'bootstrap_form'
gem 'nokogiri', '1.3.3'

group :development do
gem 'sqlite3'
gem 'pry'
gem 'pry-nav'
gem 'thin'
gem "better_errors"
Expand All @@ -23,3 +25,16 @@ group :production do
gem 'rails_12factor'
end

group :development, :test do
gem 'fabrication'
gem "faker"
gem 'rspec-rails'#, '~> 3.0.0.beta'
gem 'pry'
gem 'launchy', '~> 2.4.2'
end

group :test do
gem 'shoulda-matchers'
gem 'capybara'
end

156 changes: 100 additions & 56 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,76 +1,94 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.0.1)
actionpack (= 4.0.1)
actionmailer (4.0.4)
actionpack (= 4.0.4)
mail (~> 2.5.4)
actionpack (4.0.1)
activesupport (= 4.0.1)
actionpack (4.0.4)
activesupport (= 4.0.4)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.1)
activesupport (= 4.0.1)
activemodel (4.0.4)
activesupport (= 4.0.4)
builder (~> 3.1.0)
activerecord (4.0.1)
activemodel (= 4.0.1)
activerecord (4.0.4)
activemodel (= 4.0.4)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.1)
activesupport (= 4.0.4)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.1)
i18n (~> 0.6, >= 0.6.4)
activesupport (4.0.4)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
arel (4.0.1)
atomic (1.1.14)
better_errors (1.0.1)
addressable (2.3.6)
arel (4.0.2)
atomic (1.1.16)
bcrypt (3.1.7)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
better_errors (1.1.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap-sass (3.0.2.1)
bootstrap-sass (3.1.1.0)
sass (~> 3.2)
bootstrap_form (2.0.1)
builder (3.1.4)
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.3)
coffee-script-source (1.7.0)
daemons (1.1.9)
debug_inspector (0.0.2)
diff-lcs (1.2.5)
erubis (2.7.0)
eventmachine (1.0.0)
eventmachine (1.0.3)
execjs (2.0.2)
haml (4.0.4)
fabrication (2.11.0)
faker (1.3.0)
i18n (~> 0.5)
haml (4.0.5)
tilt
haml-rails (0.4)
actionpack (>= 3.1, < 4.1)
activesupport (>= 3.1, < 4.1)
haml (>= 3.1, < 4.1)
railties (>= 3.1, < 4.1)
haml-rails (0.5.3)
actionpack (>= 4.0.1)
activesupport (>= 4.0.1)
haml (>= 3.1, < 5.0)
railties (>= 4.0.1)
hike (1.2.3)
i18n (0.6.5)
jquery-rails (3.0.4)
i18n (0.6.9)
jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
launchy (2.4.2)
addressable (~> 2.3)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8.2)
mime-types (1.25)
mime-types (1.25.1)
minitest (4.7.5)
multi_json (1.8.2)
pg (0.17.0)
polyglot (0.3.3)
pry (0.9.12.3)
multi_json (1.9.2)
nokogiri (1.3.3)
pg (0.17.1)
polyglot (0.3.4)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
Expand All @@ -79,32 +97,47 @@ GEM
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.1)
actionmailer (= 4.0.1)
actionpack (= 4.0.1)
activerecord (= 4.0.1)
activesupport (= 4.0.1)
rails (4.0.4)
actionmailer (= 4.0.4)
actionpack (= 4.0.4)
activerecord (= 4.0.4)
activesupport (= 4.0.4)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.1)
railties (= 4.0.4)
sprockets-rails (~> 2.0.0)
rails_12factor (0.0.2)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.1)
rails_serve_static_assets (0.0.2)
rails_stdout_logging (0.0.3)
railties (4.0.1)
actionpack (= 4.0.1)
activesupport (= 4.0.1)
railties (4.0.4)
actionpack (= 4.0.4)
activesupport (= 4.0.4)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.1.0)
sass (3.2.12)
sass-rails (4.0.1)
rake (10.2.2)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
sass (3.2.18)
sass-rails (4.0.2)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0.0)
slop (3.4.7)
sprockets (2.10.0)
shoulda-matchers (2.5.0)
activesupport (>= 3.0.0)
slop (3.5.0)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
Expand All @@ -113,39 +146,50 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.8)
thin (1.5.0)
sqlite3 (1.3.9)
thin (1.6.2)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thor (0.18.1)
thread_safe (0.1.3)
atomic
thor (0.19.1)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
uglifier (2.3.1)
tzinfo (0.3.39)
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
bcrypt-ruby
better_errors
binding_of_caller
bootstrap-sass
bootstrap_form
capybara
coffee-rails
fabrication
faker
haml-rails
jquery-rails
launchy (~> 2.4.2)
nokogiri (= 1.3.3)
pg
pry
pry-nav
rails
rails (~> 4.0.4)
rails_12factor
sass-rails
rspec-rails
sass-rails (~> 4.0.2)
shoulda-matchers
sqlite3
thin
uglifier
11 changes: 11 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
class ApplicationController < ActionController::Base
protect_from_forgery

helper_method :current_user, :authorize

def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
rescue ActiveRecord::RecordNotFound
end

def authorize
redirect_to sign_in_path, alert: "Not authortized" unless current_user
end
end
5 changes: 5 additions & 0 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class CategoriesController < ApplicationController
def show
@category = Category.find(params[:id])
end
end
7 changes: 7 additions & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class PagesController < ApplicationController

def index
redirect_to videos_path if current_user
end

end
49 changes: 49 additions & 0 deletions app/controllers/queue_items_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class QueueItemsController < ApplicationController
before_action :current_user, :authorize

def index
@queue_items = current_user.queue_items
@review = Review.new
end

def create
video = Video.find_by_id(params[:video_id])
QueueItem.create(video: video, user: current_user, position: current_user.queue_items.count + 1) unless current_user.queue_items.map { |n| n.video }.include?(video)
redirect_to queue_items_path
end

def destroy
queue_item = QueueItem.find(params[:id])
queue_item.destroy if current_user.queue_items.include?(queue_item)
redirect_to queue_items_path
current_user.repositions_queue_items
end

def sort

begin
ActiveRecord::Base.transaction do
update_queue_item_position
end
rescue ActiveRecord::RecordInvalid
flash_error_message
return
end
current_user.repositions_queue_items
redirect_to(queue_items_path)
end

private

def update_queue_item_position
params[:queue_items].each do |queue_item_data|
queue_item = QueueItem.find(queue_item_data["id"])
queue_item.update!(position: queue_item_data["position"], review_rating: queue_item_data["rating"]) if queue_item.user == current_user
end
end

def flash_error_message
flash[:notice] = "Please only use whole numbers to update the queue"
redirect_to queue_items_path
end
end
23 changes: 23 additions & 0 deletions app/controllers/reviews_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class ReviewsController < ApplicationController
before_action :current_user, :authorize

def create

@video = Video.find(params[:video_id])
review = @video.reviews.create(review_params.merge!(user: current_user, video_id: @video.id))

if review.save
redirect_to video_path(@video)
else
@reviews = @video.reviews.reload
render 'videos/show'
end
end

private

def review_params
params.require(:review).permit(:content, :rating, :video_id, :user_id)
end

end
Loading