-
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
testing not finished........ #44
base: master
Are you sure you want to change the base?
Changes from all commits
3562d9b
0f34805
52f20a3
b40a986
075b2fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
/tmp/* | ||
!/log/.keep | ||
!/tmp/.keep | ||
|
||
.env | ||
|
||
# Ignore Byebug command history file. | ||
.byebug_history |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
create here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<% if logged_in? %> | ||
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. It would be much more efficient to use a controller filter to redirect those who aren't logged in. This is not very DRY as a solution. |
||
|
||
<h2>List of Users</h2> | ||
<table class="table"> | ||
<thead> | ||
|
@@ -19,3 +21,9 @@ | |
</table> | ||
|
||
<%= link_to "Back to Media List", root_path, class: "btn btn-secondary" %> | ||
|
||
<% else %> | ||
|
||
<h1> FORBIDDEN </h1> | ||
|
||
<%end%> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
<% if logged_in? %> | ||
|
||
<h2>Edit This <%= @media_category.singularize.capitalize %></h2> | ||
<%= render partial: "form" %> | ||
|
||
<% else %> | ||
|
||
<h1> FORBIDDEN </h1> | ||
|
||
<%end%> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
<% if logged_in? %> | ||
|
||
<h2>Add a new work</h2> | ||
<%= render partial: "form" %> | ||
|
||
<% else %> | ||
|
||
<h1> FORBIDDEN </h1> | ||
|
||
<%end%> |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class AddOmniauthColumnsToUserModels < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :users, :email, :string | ||
add_column :users, :provider, :string | ||
add_column :users, :uid, :integer, null: false | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
require "test_helper" | ||
|
||
describe SessionsController do | ||
let(:user) { users(:kari) } | ||
|
||
it 'logs a user out' do | ||
perform_login(user) | ||
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. what happens if you try to log out when nobody is logged in? |
||
|
||
expect{ | ||
post logout_path | ||
}.must_route_to root_path | ||
end | ||
|
||
it 'logs in an existing user' do | ||
expect{ | ||
perform_login(user) | ||
}.wont_change 'User.count' | ||
end | ||
|
||
it 'builds new users for first time log-ins' do | ||
new_user = User.new(username: 'name') | ||
|
||
expect{ | ||
perform_login(new_user) | ||
}.must_change 'User.count', 1 | ||
end | ||
|
||
end |
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.
auth_callback_path
is not what you use to access the site, it's what the site uses to get back to you about the request. You want something more like<%= link_to "Login with Github", "/auth/github" %>