Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions .byebug_history
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
quit
controller.action_name
controller.action_name "/"
action_name
controller.action "/"
action "/"
action
get :new
get :create
get :show
get show
get :new, provider: 'github', code: '123', action: "/"
quit
get :new, provider: 'github', code: '123', action: "/users/new"
quit
get :new, provider: 'github', code: '123', action: "/signin"
quit
post :new, provider: 'github', code: '123', action: "/auth/:provider/callback"quit
post :new, provider: 'github', code: '123', action: "/auth/:provider/callback"
quit
quot
quit
get :new,provider: 'github', code: '123', action: "/auth/:provider/callback"
quit
post :new, provider: 'github', code: '123'
quit
get :new
session[:id]
exit
http://www.example.com/projects/new-project
quit
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/github_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class GithubController < ApplicationController
before_action :authenticate_user!
before_action :correct_user?, :except => [:index]
before_action :correct_user?, :except => [:index, :show]

def index
client = Octokit::Client.new(:access_token => current_user.github_profile.access_token)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class UsersController < ApplicationController
before_action :authenticate_user!
before_action :correct_user?, :except => [:index]
before_action :correct_user?, :except => [:index, :show]

def index
@users = User.order('created_at DESC').paginate(page: params[:page], per_page: 30)
Expand Down
7 changes: 7 additions & 0 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
<h3>User</h3>
<p>Name: <%= @user.name if @user.name %></p>
<p>
<ul id='projects'>
<% @user.projects.each do |project|%>
<li> <%= link_to "#{project.name}", project_path(project) %></li>
<% end %>
</ul>
</p>
1 change: 0 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#
# It's strongly recommended that you check this file into your version control system.


ActiveRecord::Schema.define(version: 20160913142449) do

# These are extensions that must be enabled in order to support this database
Expand Down
16 changes: 16 additions & 0 deletions spec/features/users/profile_view_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'rails_helper'

feature 'View Profiles'do
scenario 'user can view projects of other users in devs' do
User.create!(:id => 5, :name => 'Bob')
Project.create!(:repo_id => 11111111, :name => "new project", :description => "DELETE", :user_id => 5)
visit '/'
signin
click_link 'Devs'
click_link 'Bob'
expect(page).to have_selector("ul#projects")
click_link 'new project'
expect(page).to have_content('tts-datamaster-ee-crack')
expect(page).to have_content('DELETE')
end
end
6 changes: 5 additions & 1 deletion spec/support/fake_github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
class FakeGitHub < Sinatra::Base

get '/repositories/:id' do
json_response 200, 'repos.json'
if params[:id] == 66507460
json_response 200, 'repos.json'
else
json_response 200, 'repos11111111.json'
end
end

get '/user/repos' do
Expand Down
88 changes: 4 additions & 84 deletions spec/support/fixtures/repos.json
Original file line number Diff line number Diff line change
@@ -1,89 +1,9 @@

{
{
"id": 66507460,
"name": ".atom",
"full_name": "cyberplanner/.atom",
"owner": {
"login": "cyberplanner",
"id": 16508949,
"avatar_url": "https://avatars.githubusercontent.com/u/16508949?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/cyberplanner",
"html_url": "https://github.com/cyberplanner",
"followers_url": "https://api.github.com/users/cyberplanner/followers",
"following_url": "https://api.github.com/users/cyberplanner/following{/other_user}",
"gists_url": "https://api.github.com/users/cyberplanner/gists{/gist_id}",
"starred_url": "https://api.github.com/users/cyberplanner/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cyberplanner/subscriptions",
"organizations_url": "https://api.github.com/users/cyberplanner/orgs",
"repos_url": "https://api.github.com/users/cyberplanner/repos",
"events_url": "https://api.github.com/users/cyberplanner/events{/privacy}",
"received_events_url": "https://api.github.com/users/cyberplanner/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/cyberplanner/.atom",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/cyberplanner/.atom",
"forks_url": "https://api.github.com/repos/cyberplanner/.atom/forks",
"keys_url": "https://api.github.com/repos/cyberplanner/.atom/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/cyberplanner/.atom/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/cyberplanner/.atom/teams",
"hooks_url": "https://api.github.com/repos/cyberplanner/.atom/hooks",
"issue_events_url": "https://api.github.com/repos/cyberplanner/.atom/issues/events{/number}",
"events_url": "https://api.github.com/repos/cyberplanner/.atom/events",
"assignees_url": "https://api.github.com/repos/cyberplanner/.atom/assignees{/user}",
"branches_url": "https://api.github.com/repos/cyberplanner/.atom/branches{/branch}",
"tags_url": "https://api.github.com/repos/cyberplanner/.atom/tags",
"blobs_url": "https://api.github.com/repos/cyberplanner/.atom/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/cyberplanner/.atom/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/cyberplanner/.atom/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/cyberplanner/.atom/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/cyberplanner/.atom/statuses/{sha}",
"languages_url": "https://api.github.com/repos/cyberplanner/.atom/languages",
"stargazers_url": "https://api.github.com/repos/cyberplanner/.atom/stargazers",
"contributors_url": "https://api.github.com/repos/cyberplanner/.atom/contributors",
"subscribers_url": "https://api.github.com/repos/cyberplanner/.atom/subscribers",
"subscription_url": "https://api.github.com/repos/cyberplanner/.atom/subscription",
"commits_url": "https://api.github.com/repos/cyberplanner/.atom/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/cyberplanner/.atom/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/cyberplanner/.atom/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/cyberplanner/.atom/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/cyberplanner/.atom/contents/{+path}",
"compare_url": "https://api.github.com/repos/cyberplanner/.atom/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/cyberplanner/.atom/merges",
"archive_url": "https://api.github.com/repos/cyberplanner/.atom/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/cyberplanner/.atom/downloads",
"issues_url": "https://api.github.com/repos/cyberplanner/.atom/issues{/number}",
"pulls_url": "https://api.github.com/repos/cyberplanner/.atom/pulls{/number}",
"milestones_url": "https://api.github.com/repos/cyberplanner/.atom/milestones{/number}",
"notifications_url": "https://api.github.com/repos/cyberplanner/.atom/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/cyberplanner/.atom/labels{/name}",
"releases_url": "https://api.github.com/repos/cyberplanner/.atom/releases{/id}",
"deployments_url": "https://api.github.com/repos/cyberplanner/.atom/deployments",
"created_at": "2016-08-24T23:38:46Z",
"updated_at": "2016-08-24T23:38:46Z",
"pushed_at": "2016-08-24T23:57:05Z",
"git_url": "git://github.com/cyberplanner/.atom.git",
"ssh_url": "git@github.com:cyberplanner/.atom.git",
"clone_url": "https://github.com/cyberplanner/.atom.git",
"svn_url": "https://github.com/cyberplanner/.atom",
"homepage": null,
"size": 46658,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master"
}
"id": 16508949
}
}
9 changes: 9 additions & 0 deletions spec/support/fixtures/repos11111111.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": 11111111,
"name": "tts-datamaster-ee-crack",
"full_name": "cyberplanner/.atom",
"owner": {
"login": "cyberplanner",
"id": 16508949
}
}