forked from AdaGold/media-ranker-revisited
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Melissa : Edges : MediaRanker- Revisited #31
Open
melicious-dish
wants to merge
17
commits into
Ada-C10:master
Choose a base branch
from
melicious-dish:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
40977d3
write test for create
melicious-dish 94e5afa
add tests for new in works controller
melicious-dish cee1a9a
add test for root
melicious-dish aa6c512
add omniauth
melicious-dish 313c88a
add columns for uid, provider
melicious-dish aa8b507
add username
melicious-dish c1a3f87
add update tests in session controller
melicious-dish 6a6a8b7
fix merge conflict
melicious-dish 12feec5
saved merge conflict
melicious-dish 3562fe4
save initializer and migrate files
melicious-dish 3b5e4b9
Merge branch 'master' into controller_tests
melicious-dish bbc3807
add uid and provider to user tests
melicious-dish 80fce92
add test for destroy method
melicious-dish 13983cd
add tests for users controller
melicious-dish fae43d7
work on session controller test
melicious-dish aea06f2
add user and works controller tests
melicious-dish 6a64367
uncommented tests
melicious-dish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,2 @@ | ||
GITHUB_CLIENT_ID: b36d6a8355150bead721 | ||
GITHUB_CLIENT_SECRET: 345618b701298840aec16d0cfc8b6db2fdc4ea0a |
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 |
---|---|---|
|
@@ -15,3 +15,5 @@ | |
|
||
# Ignore Byebug command history file. | ||
.byebug_history | ||
|
||
.env |
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
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
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
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,3 @@ | ||
Rails.application.config.middleware.use OmniAuth::Builder do | ||
provider :github, ENV["GITHUB_CLIENT_ID"], ENV["GITHUB_CLIENT_SECRET"], scope: "user:email" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
Rails.application.routes.draw do | ||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||
root 'works#root' | ||
get '/login', to: 'sessions#login_form', as: 'login' | ||
post '/login', to: 'sessions#login' | ||
post '/logout', to: 'sessions#logout', as: 'logout' | ||
# get '/login', to: 'sessions#login_form', as: 'login' | ||
# post '/login', to: 'sessions#login' | ||
# post '/logout', to: 'sessions#logout', as: 'logout' | ||
|
||
resources :works | ||
post '/works/:id/upvote', to: 'works#upvote', as: 'upvote' | ||
|
||
get "/auth/:provider/callback", to: "sessions#create", as: 'auth_callback' | ||
delete "/logout", to: "sessions#destroy", as: "logout" | ||
resources :users, only: [:index, :show] | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ChangeUserNameToName < ActiveRecord::Migration[5.2] | ||
def change | ||
rename_column(:users, :username, :name) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class AddEmailUidProvider < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column(:users, :email, :string) | ||
add_column(:users, :uid, :integer, null: false) | ||
add_column(:users, :provider, :string, null: false) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddUserName < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column(:users, :username, :string) | ||
end | ||
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 |
---|---|---|
|
@@ -2,4 +2,46 @@ | |
|
||
describe SessionsController do | ||
|
||
|
||
|
||
it "can successfully log in with github as an existing user" do | ||
# Arrange | ||
# make sure that for some existing user, everything is configured! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some cases missing here. What if it's a new user, or you don't get enough information to make the account? |
||
|
||
dan = users(:dan) | ||
|
||
OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new( mock_auth_hash( dan ) ) | ||
|
||
# Act | ||
# Simulating logging in with github being successful (given the OmniAuth hash made above) | ||
get auth_callback_path(:github) | ||
|
||
# Assert | ||
|
||
must_respond_with :success | ||
expect(session[:user_id]).must_equal dan.id | ||
expect(flash[:success]).must_equal "Logged in as returning user #{dan.name}" | ||
|
||
end | ||
|
||
|
||
end | ||
|
||
describe "destroy" do | ||
it "can logout a user" do | ||
|
||
dan = users(:dan) | ||
|
||
OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new( mock_auth_hash( dan ) ) | ||
|
||
get auth_callback_path(:github) | ||
|
||
expect ( session[:user_id] ).must_equal users(:dan.id) | ||
|
||
delete logout_path | ||
|
||
must_respond_with :redirect | ||
must_redirect_to root_path | ||
end | ||
|
||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a TODO anymore