{"action":"created","comment":{"url":"https://api.github.com/repos/fsek/web/pulls/comments/26874653","id":26874653,"diff_hunk":"@@ -0,0 +1,156 @@\n+require 'rails_helper'\n+\n+RSpec.describe Election::CandidatesController, type: :controller do\n+\n+  # Override get_commit\n+  before(:each) do\n+    allow_any_instance_of(ApplicationController).to receive(:get_commit).and_return(true)\n+  end\n+  # Build an election\n+  let(:election) { create(:election) }\n+  before(:each) do\n+    allow(Election).to receive(:current).and_return(election)\n+  end\n+  # Testing objects\n+  let(:user) { create(:user) }\n+  let(:search_post) { create(:post) }\n+  let(:not_owner) { create(:user) }\n+  let(:candidate) { create(:candidate, profile: user.profile,\n+                           election: election, post: search_post) }\n+\n+\n+  context 'when not signed in' do\n+    describe 'GET #index' do\n+      it 'redirects' do\n+        get :index\n+\n+        expect(response).to be_redirect\n+      end\n+    end\n+  end\n+\n+  context 'when signed in as user' do\n+    before do\n+      sign_in user\n+      search_post\n+    end\n+    it \"should have a current_user\" do\n+      expect(subject.current_user).to_not be_nil\n+    end\n+    describe 'GET #index' do\n+      it 'succeeds' do\n+        get :index\n+\n+        expect(response).to be_success\n+      end\n+      it 'assigns users candidates' do\n+        get :index\n+\n+        expect(assigns(:candidates)).to eq(user.profile.candidates.where(election: election))\n+      end\n+    end\n+    describe 'GET #new' do\n+      it 'succeeds' do\n+        get :new\n+\n+        expect(response).to be_success\n+      end\n+      it 'prepares new candidate with user' do\n+        get :new\n+\n+        expect(assigns(:candidate).name).to eq(user.profile.name)\n+      end\n+    end\n+    describe 'GET #show' do\n+      it 'do not diplay an error flash' do\n+        get :show, id: candidate.id\n+\n+        expect(flash[:error]).to_not eq('Du har inte rättigheter för att se kandidaturen.')\n+      end\n+    end\n+    describe 'POST #create' do\n+      before { search_post  }\n+      it 'creates a new candidate' do\n+        expect {\n+          post :create, {candidate: attributes_for(:candidate, post_id: search_post.id)}\n+        }.to change(Candidate, :count).by(1)\n+      end\n+      it 'creates candidate and redirects to candidate' do\n+        post :create, {candidate: attributes_for(:candidate, post_id: search_post.id)}\n+        expect(response).to redirect_to([:election, Candidate.last])\n+      end\n+    end\n+\n+    describe \"PATCH #update\" do\n+      before { candidate }\n+      let(:change_attributes) { {name: \"David\", lastname: \"Ny\", stil_id: \"Nytt\"} }\n+      context \"with valid params\" do\n+        it \"updates the requested candidate\" do\n+          patch :update, {id: candidate.to_param, candidate: change_attributes}\n+          candidate.reload\n+          expect(candidate.name == change_attributes[:name] &&\n+                     candidate.lastname == change_attributes[:lastname]).to be_truthy\n+        end\n+\n+        it \"assigns the requested candidate as @candidate\" do\n+          patch :update, {id: candidate.to_param, candidate: change_attributes}\n+          expect(assigns(:candidate)).to eq(candidate)\n+        end\n+\n+        it \"redirects to the candidate\" do\n+          patch :update, {id: candidate.to_param, candidate: change_attributes}","path":"spec/controllers/election/candidates_controller_spec.rb","position":null,"original_position":101,"commit_id":"03faaac58759187040d9e5fbd1e3906cd79ea02b","original_commit_id":"901803bf0234db473bb806b0f265abcc93bfca58","user":{"login":"Zofz","id":6763624,"avatar_url":"https://avatars.githubusercontent.com/u/6763624?v=3","gravatar_id":"","url":"https://api.github.com/users/Zofz","html_url":"https://github.com/Zofz","followers_url":"https://api.github.com/users/Zofz/followers","following_url":"https://api.github.com/users/Zofz/following{/other_user}","gists_url":"https://api.github.com/users/Zofz/gists{/gist_id}","starred_url":"https://api.github.com/users/Zofz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zofz/subscriptions","organizations_url":"https://api.github.com/users/Zofz/orgs","repos_url":"https://api.github.com/users/Zofz/repos","events_url":"https://api.github.com/users/Zofz/events{/privacy}","received_events_url":"https://api.github.com/users/Zofz/received_events","type":"User","site_admin":false},"body":"This one is changed, but Hound won't update..","created_at":"2015-03-20T20:44:05Z","updated_at":"2015-03-20T20:44:05Z","html_url":"https://github.com/fsek/web/pull/70#discussion_r26874653","pull_request_url":"https://api.github.com/repos/fsek/web/pulls/70","_links":{"self":{"href":"https://api.github.com/repos/fsek/web/pulls/comments/26874653"},"html":{"href":"https://github.com/fsek/web/pull/70#discussion_r26874653"},"pull_request":{"href":"https://api.github.com/repos/fsek/web/pulls/70"}}},"pull_request":{"url":"https://api.github.com/repos/fsek/web/pulls/70","id":31518081,"html_url":"https://github.com/fsek/web/pull/70","diff_url":"https://github.com/fsek/web/pull/70.diff","patch_url":"https://github.com/fsek/web/pull/70.patch","issue_url":"https://api.github.com/repos/fsek/web/issues/70","number":70,"state":"open","locked":false,"title":"Controller tests","user":{"login":"henrikssn","id":859779,"avatar_url":"https://avatars.githubusercontent.com/u/859779?v=3","gravatar_id":"","url":"https://api.github.com/users/henrikssn","html_url":"https://github.com/henrikssn","followers_url":"https://api.github.com/users/henrikssn/followers","following_url":"https://api.github.com/users/henrikssn/following{/other_user}","gists_url":"https://api.github.com/users/henrikssn/gists{/gist_id}","starred_url":"https://api.github.com/users/henrikssn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henrikssn/subscriptions","organizations_url":"https://api.github.com/users/henrikssn/orgs","repos_url":"https://api.github.com/users/henrikssn/repos","events_url":"https://api.github.com/users/henrikssn/events{/privacy}","received_events_url":"https://api.github.com/users/henrikssn/received_events","type":"User","site_admin":false},"body":"Adds controller tests.\r\n\r\nWe should start focusing on authentication tests to support #69.\r\n\r\nWork in progress. Help is welcome.","created_at":"2015-03-19T12:22:04Z","updated_at":"2015-03-20T20:44:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e990ed2990d92422fcd9a4260313a981063abbe5","assignee":null,"milestone":{"url":"https://api.github.com/repos/fsek/web/milestones/10","html_url":"https://github.com/fsek/web/milestones/Testing","labels_url":"https://api.github.com/repos/fsek/web/milestones/10/labels","id":990743,"number":10,"title":"Testing","description":null,"creator":{"login":"Zofz","id":6763624,"avatar_url":"https://avatars.githubusercontent.com/u/6763624?v=3","gravatar_id":"","url":"https://api.github.com/users/Zofz","html_url":"https://github.com/Zofz","followers_url":"https://api.github.com/users/Zofz/followers","following_url":"https://api.github.com/users/Zofz/following{/other_user}","gists_url":"https://api.github.com/users/Zofz/gists{/gist_id}","starred_url":"https://api.github.com/users/Zofz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zofz/subscriptions","organizations_url":"https://api.github.com/users/Zofz/orgs","repos_url":"https://api.github.com/users/Zofz/repos","events_url":"https://api.github.com/users/Zofz/events{/privacy}","received_events_url":"https://api.github.com/users/Zofz/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":3,"state":"open","created_at":"2015-02-23T06:47:18Z","updated_at":"2015-03-20T20:22:54Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/fsek/web/pulls/70/commits","review_comments_url":"https://api.github.com/repos/fsek/web/pulls/70/comments","review_comment_url":"https://api.github.com/repos/fsek/web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fsek/web/issues/70/comments","statuses_url":"https://api.github.com/repos/fsek/web/statuses/03faaac58759187040d9e5fbd1e3906cd79ea02b","head":{"label":"fsek:auth-test","ref":"auth-test","sha":"03faaac58759187040d9e5fbd1e3906cd79ea02b","user":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"repo":{"id":27583674,"name":"web","full_name":"fsek/web","owner":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fsek/web","description":"F-sektionens hemsida","fork":false,"url":"https://api.github.com/repos/fsek/web","forks_url":"https://api.github.com/repos/fsek/web/forks","keys_url":"https://api.github.com/repos/fsek/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fsek/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fsek/web/teams","hooks_url":"https://api.github.com/repos/fsek/web/hooks","issue_events_url":"https://api.github.com/repos/fsek/web/issues/events{/number}","events_url":"https://api.github.com/repos/fsek/web/events","assignees_url":"https://api.github.com/repos/fsek/web/assignees{/user}","branches_url":"https://api.github.com/repos/fsek/web/branches{/branch}","tags_url":"https://api.github.com/repos/fsek/web/tags","blobs_url":"https://api.github.com/repos/fsek/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fsek/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fsek/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/fsek/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fsek/web/statuses/{sha}","languages_url":"https://api.github.com/repos/fsek/web/languages","stargazers_url":"https://api.github.com/repos/fsek/web/stargazers","contributors_url":"https://api.github.com/repos/fsek/web/contributors","subscribers_url":"https://api.github.com/repos/fsek/web/subscribers","subscription_url":"https://api.github.com/repos/fsek/web/subscription","commits_url":"https://api.github.com/repos/fsek/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/fsek/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/fsek/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/fsek/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/fsek/web/contents/{+path}","compare_url":"https://api.github.com/repos/fsek/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fsek/web/merges","archive_url":"https://api.github.com/repos/fsek/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fsek/web/downloads","issues_url":"https://api.github.com/repos/fsek/web/issues{/number}","pulls_url":"https://api.github.com/repos/fsek/web/pulls{/number}","milestones_url":"https://api.github.com/repos/fsek/web/milestones{/number}","notifications_url":"https://api.github.com/repos/fsek/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fsek/web/labels{/name}","releases_url":"https://api.github.com/repos/fsek/web/releases{/id}","created_at":"2014-12-05T09:13:19Z","updated_at":"2015-03-20T20:17:59Z","pushed_at":"2015-03-20T20:42:26Z","git_url":"git://github.com/fsek/web.git","ssh_url":"git@github.com:fsek/web.git","clone_url":"https://github.com/fsek/web.git","svn_url":"https://github.com/fsek/web","homepage":"http://fsektionen.se","size":209329,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":38,"forks":1,"open_issues":38,"watchers":1,"default_branch":"master"}},"base":{"label":"fsek:master","ref":"master","sha":"46fe2b3116f8730ba9d4525368b9a054010c7533","user":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"repo":{"id":27583674,"name":"web","full_name":"fsek/web","owner":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fsek/web","description":"F-sektionens hemsida","fork":false,"url":"https://api.github.com/repos/fsek/web","forks_url":"https://api.github.com/repos/fsek/web/forks","keys_url":"https://api.github.com/repos/fsek/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fsek/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fsek/web/teams","hooks_url":"https://api.github.com/repos/fsek/web/hooks","issue_events_url":"https://api.github.com/repos/fsek/web/issues/events{/number}","events_url":"https://api.github.com/repos/fsek/web/events","assignees_url":"https://api.github.com/repos/fsek/web/assignees{/user}","branches_url":"https://api.github.com/repos/fsek/web/branches{/branch}","tags_url":"https://api.github.com/repos/fsek/web/tags","blobs_url":"https://api.github.com/repos/fsek/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fsek/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fsek/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/fsek/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fsek/web/statuses/{sha}","languages_url":"https://api.github.com/repos/fsek/web/languages","stargazers_url":"https://api.github.com/repos/fsek/web/stargazers","contributors_url":"https://api.github.com/repos/fsek/web/contributors","subscribers_url":"https://api.github.com/repos/fsek/web/subscribers","subscription_url":"https://api.github.com/repos/fsek/web/subscription","commits_url":"https://api.github.com/repos/fsek/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/fsek/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/fsek/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/fsek/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/fsek/web/contents/{+path}","compare_url":"https://api.github.com/repos/fsek/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fsek/web/merges","archive_url":"https://api.github.com/repos/fsek/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fsek/web/downloads","issues_url":"https://api.github.com/repos/fsek/web/issues{/number}","pulls_url":"https://api.github.com/repos/fsek/web/pulls{/number}","milestones_url":"https://api.github.com/repos/fsek/web/milestones{/number}","notifications_url":"https://api.github.com/repos/fsek/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fsek/web/labels{/name}","releases_url":"https://api.github.com/repos/fsek/web/releases{/id}","created_at":"2014-12-05T09:13:19Z","updated_at":"2015-03-20T20:17:59Z","pushed_at":"2015-03-20T20:42:26Z","git_url":"git://github.com/fsek/web.git","ssh_url":"git@github.com:fsek/web.git","clone_url":"https://github.com/fsek/web.git","svn_url":"https://github.com/fsek/web","homepage":"http://fsektionen.se","size":209329,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":38,"forks":1,"open_issues":38,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fsek/web/pulls/70"},"html":{"href":"https://github.com/fsek/web/pull/70"},"issue":{"href":"https://api.github.com/repos/fsek/web/issues/70"},"comments":{"href":"https://api.github.com/repos/fsek/web/issues/70/comments"},"review_comments":{"href":"https://api.github.com/repos/fsek/web/pulls/70/comments"},"review_comment":{"href":"https://api.github.com/repos/fsek/web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fsek/web/pulls/70/commits"},"statuses":{"href":"https://api.github.com/repos/fsek/web/statuses/03faaac58759187040d9e5fbd1e3906cd79ea02b"}}}}