{"action":"created","comment":{"url":"https://api.github.com/repos/DianeRt/crud/pulls/comments/58313988","id":58313988,"diff_hunk":"@@ -0,0 +1,96 @@\n+require_relative 'spec_helper'\n+\n+def app\n+  UsersController.new\n+end\n+\n+describe UsersController do\n+  before do\n+    @users = DB[:users]\n+  end\n+ \n+  #-------------------------------------------------------------------------------------\n+  describe \"when logged in as an admin\" do\n+    before do\n+      @admin = @users.where(admin: true).first\n+      env \"rack.session\", {:current_user_id => @admin[:id]}\n+    end\n+\n+    it \"able to access '/users' page\" do\n+      get '/users'\n+      last_response.body.must_include \"Complete CRUD Users\"\n+    end\n+\n+    it \"able to access other user's page\" do\n+      different_user_id = @admin[:id] + 1\n+      get \"/users/#{different_user_id}\"\n+      last_response.body.must_include \"User Info\"\n+    end\n+\n+    it \"displays all users '/users' page\" do\n+      number_of_users = @users.count\n+      get '/users'\n+      users_page = Nokogiri::HTML(last_response.body)\n+      li_size = users_page.search(\"li\").size\n+      li_size.must_equal number_of_users\n+    end\n+  end\n+\n+  #-------------------------------------------------------------------------------------\n+  describe \"when logged in as a regular user\" do\n+    before do\n+      @regular_user = @users.where(admin: false).first\n+      env \"rack.session\", {:current_user_id => @regular_user[:id]}\n+    end\n+\n+    it \"can view own page\" do\n+      get \"/users/#{@regular_user[:id]}\"\n+      last_response.body.must_include \"User Info\"\n+    end\n+\n+    it \"redirects regular_user when accessing '/users' page\" do\n+      get '/users'\n+      follow_redirect!\n+      last_response.body.must_include \"Unauthorized access\"\n+    end\n+\n+    it \"redirects regular_user when accessing other user's page\" do\n+      different_user_id = @regular_user[:id] + 1    \n+      get \"/users/#{different_user_id}\"\n+      follow_redirect!\n+      last_response.body.must_include \"Unauthorized access\"\n+    end\n+  end\n+\n+  #-------------------------------------------------------------------------------------\n+  describe \"testing login, create, update and delete\" do\n+    before do\n+      post '/users', params = {fname: \"f3\", lname: \"l3\", email: \"e3\", username: \"u3\", password: \"p3\"}\n+      @current_user = @users.where(fname: \"f3\").first\n+    end\n+\n+    it \"successfully creates a new user\" do\n+      @current_user.wont_be_nil\n+    end\n+\n+    it \"successfully logs in a user\" do\n+      post '/users/login', params = {username: \"u3\", password: \"p3\"}\n+      follow_redirect!\n+      last_response.body.must_include \"User Info\"\n+    end\n+\n+    it \"updates current_user info\" do\n+      env \"rack.session\", {:current_user_id => @current_user[:id]}\n+      patch \"/users/#{@current_user[:id]}\", params = {fname: \"FNAME\", lname: \"l3\", email: \"e3\", username: \"u3\", password: \"p3\"}\n+      follow_redirect!\n+      last_response.body.must_include \"Successfully updated user info\"\n+    end\n+\n+    it \"deletes current_user account\" do\n+      current_user_id = @current_user[:id]\n+      delete \"/users/#{current_user_id}\"\n+      deleted_user = @users.where(id: current_user_id).first\n+      deleted_user.must_be_nil","path":"spec/users_controller_spec.rb","position":93,"original_position":93,"commit_id":"f6197986b2a067428825413916899920b956b142","original_commit_id":"f6197986b2a067428825413916899920b956b142","user":{"login":"gjaldon","id":1457730,"avatar_url":"https://avatars.githubusercontent.com/u/1457730?v=3","gravatar_id":"","url":"https://api.github.com/users/gjaldon","html_url":"https://github.com/gjaldon","followers_url":"https://api.github.com/users/gjaldon/followers","following_url":"https://api.github.com/users/gjaldon/following{/other_user}","gists_url":"https://api.github.com/users/gjaldon/gists{/gist_id}","starred_url":"https://api.github.com/users/gjaldon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjaldon/subscriptions","organizations_url":"https://api.github.com/users/gjaldon/orgs","repos_url":"https://api.github.com/users/gjaldon/repos","events_url":"https://api.github.com/users/gjaldon/events{/privacy}","received_events_url":"https://api.github.com/users/gjaldon/received_events","type":"User","site_admin":false},"body":"Very nice and clear test case. :+1: ","created_at":"2016-04-03T17:33:06Z","updated_at":"2016-04-03T17:33:06Z","html_url":"https://github.com/DianeRt/crud/pull/11#discussion_r58313988","pull_request_url":"https://api.github.com/repos/DianeRt/crud/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/comments/58313988"},"html":{"href":"https://github.com/DianeRt/crud/pull/11#discussion_r58313988"},"pull_request":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/DianeRt/crud/pulls/11","id":65062952,"html_url":"https://github.com/DianeRt/crud/pull/11","diff_url":"https://github.com/DianeRt/crud/pull/11.diff","patch_url":"https://github.com/DianeRt/crud/pull/11.patch","issue_url":"https://api.github.com/repos/DianeRt/crud/issues/11","number":11,"state":"open","locked":false,"title":"Minitest","user":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"body":"@gjaldon Done with issue #6. Ran the tests by typing 'rake mini:test' in the terminal. All tests passed.","created_at":"2016-04-03T08:49:55Z","updated_at":"2016-04-03T17:33:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"21ce0af4baf4b7d86e5174ca0ab4ddd0029e76e2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DianeRt/crud/pulls/11/commits","review_comments_url":"https://api.github.com/repos/DianeRt/crud/pulls/11/comments","review_comment_url":"https://api.github.com/repos/DianeRt/crud/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DianeRt/crud/issues/11/comments","statuses_url":"https://api.github.com/repos/DianeRt/crud/statuses/f6197986b2a067428825413916899920b956b142","head":{"label":"DianeRt:minitest","ref":"minitest","sha":"f6197986b2a067428825413916899920b956b142","user":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"repo":{"id":52657470,"name":"crud","full_name":"DianeRt/crud","owner":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DianeRt/crud","description":"","fork":false,"url":"https://api.github.com/repos/DianeRt/crud","forks_url":"https://api.github.com/repos/DianeRt/crud/forks","keys_url":"https://api.github.com/repos/DianeRt/crud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DianeRt/crud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DianeRt/crud/teams","hooks_url":"https://api.github.com/repos/DianeRt/crud/hooks","issue_events_url":"https://api.github.com/repos/DianeRt/crud/issues/events{/number}","events_url":"https://api.github.com/repos/DianeRt/crud/events","assignees_url":"https://api.github.com/repos/DianeRt/crud/assignees{/user}","branches_url":"https://api.github.com/repos/DianeRt/crud/branches{/branch}","tags_url":"https://api.github.com/repos/DianeRt/crud/tags","blobs_url":"https://api.github.com/repos/DianeRt/crud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DianeRt/crud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DianeRt/crud/git/refs{/sha}","trees_url":"https://api.github.com/repos/DianeRt/crud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DianeRt/crud/statuses/{sha}","languages_url":"https://api.github.com/repos/DianeRt/crud/languages","stargazers_url":"https://api.github.com/repos/DianeRt/crud/stargazers","contributors_url":"https://api.github.com/repos/DianeRt/crud/contributors","subscribers_url":"https://api.github.com/repos/DianeRt/crud/subscribers","subscription_url":"https://api.github.com/repos/DianeRt/crud/subscription","commits_url":"https://api.github.com/repos/DianeRt/crud/commits{/sha}","git_commits_url":"https://api.github.com/repos/DianeRt/crud/git/commits{/sha}","comments_url":"https://api.github.com/repos/DianeRt/crud/comments{/number}","issue_comment_url":"https://api.github.com/repos/DianeRt/crud/issues/comments{/number}","contents_url":"https://api.github.com/repos/DianeRt/crud/contents/{+path}","compare_url":"https://api.github.com/repos/DianeRt/crud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DianeRt/crud/merges","archive_url":"https://api.github.com/repos/DianeRt/crud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DianeRt/crud/downloads","issues_url":"https://api.github.com/repos/DianeRt/crud/issues{/number}","pulls_url":"https://api.github.com/repos/DianeRt/crud/pulls{/number}","milestones_url":"https://api.github.com/repos/DianeRt/crud/milestones{/number}","notifications_url":"https://api.github.com/repos/DianeRt/crud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DianeRt/crud/labels{/name}","releases_url":"https://api.github.com/repos/DianeRt/crud/releases{/id}","deployments_url":"https://api.github.com/repos/DianeRt/crud/deployments","created_at":"2016-02-27T08:28:13Z","updated_at":"2016-02-27T08:52:44Z","pushed_at":"2016-04-03T08:49:55Z","git_url":"git://github.com/DianeRt/crud.git","ssh_url":"git@github.com:DianeRt/crud.git","clone_url":"https://github.com/DianeRt/crud.git","svn_url":"https://github.com/DianeRt/crud","homepage":null,"size":30,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"base":{"label":"DianeRt:master","ref":"master","sha":"3448cfd9722fe46db642a2792321108e619ee922","user":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"repo":{"id":52657470,"name":"crud","full_name":"DianeRt/crud","owner":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DianeRt/crud","description":"","fork":false,"url":"https://api.github.com/repos/DianeRt/crud","forks_url":"https://api.github.com/repos/DianeRt/crud/forks","keys_url":"https://api.github.com/repos/DianeRt/crud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DianeRt/crud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DianeRt/crud/teams","hooks_url":"https://api.github.com/repos/DianeRt/crud/hooks","issue_events_url":"https://api.github.com/repos/DianeRt/crud/issues/events{/number}","events_url":"https://api.github.com/repos/DianeRt/crud/events","assignees_url":"https://api.github.com/repos/DianeRt/crud/assignees{/user}","branches_url":"https://api.github.com/repos/DianeRt/crud/branches{/branch}","tags_url":"https://api.github.com/repos/DianeRt/crud/tags","blobs_url":"https://api.github.com/repos/DianeRt/crud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DianeRt/crud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DianeRt/crud/git/refs{/sha}","trees_url":"https://api.github.com/repos/DianeRt/crud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DianeRt/crud/statuses/{sha}","languages_url":"https://api.github.com/repos/DianeRt/crud/languages","stargazers_url":"https://api.github.com/repos/DianeRt/crud/stargazers","contributors_url":"https://api.github.com/repos/DianeRt/crud/contributors","subscribers_url":"https://api.github.com/repos/DianeRt/crud/subscribers","subscription_url":"https://api.github.com/repos/DianeRt/crud/subscription","commits_url":"https://api.github.com/repos/DianeRt/crud/commits{/sha}","git_commits_url":"https://api.github.com/repos/DianeRt/crud/git/commits{/sha}","comments_url":"https://api.github.com/repos/DianeRt/crud/comments{/number}","issue_comment_url":"https://api.github.com/repos/DianeRt/crud/issues/comments{/number}","contents_url":"https://api.github.com/repos/DianeRt/crud/contents/{+path}","compare_url":"https://api.github.com/repos/DianeRt/crud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DianeRt/crud/merges","archive_url":"https://api.github.com/repos/DianeRt/crud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DianeRt/crud/downloads","issues_url":"https://api.github.com/repos/DianeRt/crud/issues{/number}","pulls_url":"https://api.github.com/repos/DianeRt/crud/pulls{/number}","milestones_url":"https://api.github.com/repos/DianeRt/crud/milestones{/number}","notifications_url":"https://api.github.com/repos/DianeRt/crud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DianeRt/crud/labels{/name}","releases_url":"https://api.github.com/repos/DianeRt/crud/releases{/id}","deployments_url":"https://api.github.com/repos/DianeRt/crud/deployments","created_at":"2016-02-27T08:28:13Z","updated_at":"2016-02-27T08:52:44Z","pushed_at":"2016-04-03T08:49:55Z","git_url":"git://github.com/DianeRt/crud.git","ssh_url":"git@github.com:DianeRt/crud.git","clone_url":"https://github.com/DianeRt/crud.git","svn_url":"https://github.com/DianeRt/crud","homepage":null,"size":30,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/11"},"html":{"href":"https://github.com/DianeRt/crud/pull/11"},"issue":{"href":"https://api.github.com/repos/DianeRt/crud/issues/11"},"comments":{"href":"https://api.github.com/repos/DianeRt/crud/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/DianeRt/crud/statuses/f6197986b2a067428825413916899920b956b142"}}}}