{"action":"created","comment":{"url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/comments/25474886","id":25474886,"diff_hunk":"@@ -22,38 +19,60 @@\n     end\n \n     context \"good email\" do\n-      context \"new user\" do\n-        before { get :index, { email: 'user@example.com' } }\n+      let!(:campaign) { FactoryGirl.create(:campaign_with_reps, count: 3, priority: 1) }\n+      let (:state)    { FactoryGirl.create(:state, abbrev: 'CA') }\n+      let (:district) { FactoryGirl.create(:district, district: '13', state: state) }\n+      let!(:senator)  { FactoryGirl.create(:senator, state: state, with_us: false) }\n+      let!(:rep)      { FactoryGirl.create(:representative, district: district,\n+                                                            with_us: true) }\n+      let(:campaign_ids) { campaign.legislators.pluck(:id) }\n+      let(:returned_ids) { assigns(:target_legislators).map{|tl| tl['id']} }","path":"spec/controllers/v1/legislators_controller_spec.rb","position":23,"original_position":23,"commit_id":"c08621655c97364b9b53d9016f6101c53d913eb3","original_commit_id":"612b14bc37565a8101691c61ca4f482c6582876c","user":{"login":"Rio517","id":14241,"avatar_url":"https://avatars.githubusercontent.com/u/14241?v=3","gravatar_id":"","url":"https://api.github.com/users/Rio517","html_url":"https://github.com/Rio517","followers_url":"https://api.github.com/users/Rio517/followers","following_url":"https://api.github.com/users/Rio517/following{/other_user}","gists_url":"https://api.github.com/users/Rio517/gists{/gist_id}","starred_url":"https://api.github.com/users/Rio517/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rio517/subscriptions","organizations_url":"https://api.github.com/users/Rio517/orgs","repos_url":"https://api.github.com/users/Rio517/repos","events_url":"https://api.github.com/users/Rio517/events{/privacy}","received_events_url":"https://api.github.com/users/Rio517/received_events","type":"User","site_admin":false},"body":"I don't think fixtures and factories should be used together. Factories are meant to take the place of fixtures. As you've written it above, I might have just used a before block and then `@lala` for each variable that needed to actually be called in your tests.  Still, I wouldn't worry too much. You might focus on using the before block rather than so many lets, but I don't think either makes a critical difference right now.\r\n\r\nGenerally, Rails controller specs make it easy to mix what should really be acceptance or integration tests in with what should be more functional testing.  In the ideal situation, we'd use mocks in functional controller testing - testing isolated bits of interaction without retesting what should be tested in unit tests in the model.  In our app, I wrote out several such mocks in the calls_controller spec if you want to see an example.\r\n\r\nIf we stick to skinny controllers, there are a lot fewer interactions to test in your controller and only a few objects that you actually need to mock out. Mocking takes a bit of time to learn to do well and quickly, but usually it saves you time over the long run and better isolates the behavior your trying to test.\r\n\r\nKeep in mind, with `FactoryGirl.create` you're actually hitting the DB for each of these tests, slowing things down - especially as test suites grow. Sometimes, `FactoryGirl.build` can be used instead, but it won't persist data.  Ideally, factories would be used to build real database records only when absolutely needed.  By this nature, factory build objects will mostly be found in acceptance/feature or integration testing (although, I think I broke this rule at least once) and avoided elsewhere.\r\n\r\nMake sense? I hope that's helpful.\r\n","created_at":"2015-02-26T23:10:58Z","updated_at":"2015-02-26T23:10:58Z","html_url":"https://github.com/MayOneUS/mayday-2.0-backend/pull/11#discussion_r25474886","pull_request_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/comments/25474886"},"html":{"href":"https://github.com/MayOneUS/mayday-2.0-backend/pull/11#discussion_r25474886"},"pull_request":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/11","id":30120739,"html_url":"https://github.com/MayOneUS/mayday-2.0-backend/pull/11","diff_url":"https://github.com/MayOneUS/mayday-2.0-backend/pull/11.diff","patch_url":"https://github.com/MayOneUS/mayday-2.0-backend/pull/11.patch","issue_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/11","number":11,"state":"open","locked":false,"title":"Rep lookup","user":{"login":"turino","id":9420188,"avatar_url":"https://avatars.githubusercontent.com/u/9420188?v=3","gravatar_id":"","url":"https://api.github.com/users/turino","html_url":"https://github.com/turino","followers_url":"https://api.github.com/users/turino/followers","following_url":"https://api.github.com/users/turino/following{/other_user}","gists_url":"https://api.github.com/users/turino/gists{/gist_id}","starred_url":"https://api.github.com/users/turino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turino/subscriptions","organizations_url":"https://api.github.com/users/turino/orgs","repos_url":"https://api.github.com/users/turino/repos","events_url":"https://api.github.com/users/turino/events{/privacy}","received_events_url":"https://api.github.com/users/turino/received_events","type":"User","site_admin":false},"body":"moved logic from view to LegislatorsController","created_at":"2015-02-26T21:57:44Z","updated_at":"2015-02-26T23:10:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32d754742979a63a0a9c00c6d4730b840317bc0f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/11/commits","review_comments_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/11/comments","review_comment_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/11/comments","statuses_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/statuses/c08621655c97364b9b53d9016f6101c53d913eb3","head":{"label":"MayOneUS:rep-lookup","ref":"rep-lookup","sha":"c08621655c97364b9b53d9016f6101c53d913eb3","user":{"login":"MayOneUS","id":7469720,"avatar_url":"https://avatars.githubusercontent.com/u/7469720?v=3","gravatar_id":"","url":"https://api.github.com/users/MayOneUS","html_url":"https://github.com/MayOneUS","followers_url":"https://api.github.com/users/MayOneUS/followers","following_url":"https://api.github.com/users/MayOneUS/following{/other_user}","gists_url":"https://api.github.com/users/MayOneUS/gists{/gist_id}","starred_url":"https://api.github.com/users/MayOneUS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MayOneUS/subscriptions","organizations_url":"https://api.github.com/users/MayOneUS/orgs","repos_url":"https://api.github.com/users/MayOneUS/repos","events_url":"https://api.github.com/users/MayOneUS/events{/privacy}","received_events_url":"https://api.github.com/users/MayOneUS/received_events","type":"Organization","site_admin":false},"repo":{"id":29715441,"name":"mayday-2.0-backend","full_name":"MayOneUS/mayday-2.0-backend","owner":{"login":"MayOneUS","id":7469720,"avatar_url":"https://avatars.githubusercontent.com/u/7469720?v=3","gravatar_id":"","url":"https://api.github.com/users/MayOneUS","html_url":"https://github.com/MayOneUS","followers_url":"https://api.github.com/users/MayOneUS/followers","following_url":"https://api.github.com/users/MayOneUS/following{/other_user}","gists_url":"https://api.github.com/users/MayOneUS/gists{/gist_id}","starred_url":"https://api.github.com/users/MayOneUS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MayOneUS/subscriptions","organizations_url":"https://api.github.com/users/MayOneUS/orgs","repos_url":"https://api.github.com/users/MayOneUS/repos","events_url":"https://api.github.com/users/MayOneUS/events{/privacy}","received_events_url":"https://api.github.com/users/MayOneUS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MayOneUS/mayday-2.0-backend","description":"The API-driven next generation MADAY.us site","fork":false,"url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend","forks_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/forks","keys_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/teams","hooks_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/hooks","issue_events_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/events{/number}","events_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/events","assignees_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/assignees{/user}","branches_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/branches{/branch}","tags_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/tags","blobs_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/languages","stargazers_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/stargazers","contributors_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/contributors","subscribers_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/subscribers","subscription_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/subscription","commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/contents/{+path}","compare_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/merges","archive_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/downloads","issues_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues{/number}","pulls_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/labels{/name}","releases_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/releases{/id}","created_at":"2015-01-23T03:50:45Z","updated_at":"2015-02-26T22:00:19Z","pushed_at":"2015-02-26T22:57:39Z","git_url":"git://github.com/MayOneUS/mayday-2.0-backend.git","ssh_url":"git@github.com:MayOneUS/mayday-2.0-backend.git","clone_url":"https://github.com/MayOneUS/mayday-2.0-backend.git","svn_url":"https://github.com/MayOneUS/mayday-2.0-backend","homepage":null,"size":1984,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"MayOneUS:master","ref":"master","sha":"e1393a26ae43d485890afbbfc34e44661b0e0db0","user":{"login":"MayOneUS","id":7469720,"avatar_url":"https://avatars.githubusercontent.com/u/7469720?v=3","gravatar_id":"","url":"https://api.github.com/users/MayOneUS","html_url":"https://github.com/MayOneUS","followers_url":"https://api.github.com/users/MayOneUS/followers","following_url":"https://api.github.com/users/MayOneUS/following{/other_user}","gists_url":"https://api.github.com/users/MayOneUS/gists{/gist_id}","starred_url":"https://api.github.com/users/MayOneUS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MayOneUS/subscriptions","organizations_url":"https://api.github.com/users/MayOneUS/orgs","repos_url":"https://api.github.com/users/MayOneUS/repos","events_url":"https://api.github.com/users/MayOneUS/events{/privacy}","received_events_url":"https://api.github.com/users/MayOneUS/received_events","type":"Organization","site_admin":false},"repo":{"id":29715441,"name":"mayday-2.0-backend","full_name":"MayOneUS/mayday-2.0-backend","owner":{"login":"MayOneUS","id":7469720,"avatar_url":"https://avatars.githubusercontent.com/u/7469720?v=3","gravatar_id":"","url":"https://api.github.com/users/MayOneUS","html_url":"https://github.com/MayOneUS","followers_url":"https://api.github.com/users/MayOneUS/followers","following_url":"https://api.github.com/users/MayOneUS/following{/other_user}","gists_url":"https://api.github.com/users/MayOneUS/gists{/gist_id}","starred_url":"https://api.github.com/users/MayOneUS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MayOneUS/subscriptions","organizations_url":"https://api.github.com/users/MayOneUS/orgs","repos_url":"https://api.github.com/users/MayOneUS/repos","events_url":"https://api.github.com/users/MayOneUS/events{/privacy}","received_events_url":"https://api.github.com/users/MayOneUS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MayOneUS/mayday-2.0-backend","description":"The API-driven next generation MADAY.us site","fork":false,"url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend","forks_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/forks","keys_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/teams","hooks_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/hooks","issue_events_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/events{/number}","events_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/events","assignees_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/assignees{/user}","branches_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/branches{/branch}","tags_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/tags","blobs_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/languages","stargazers_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/stargazers","contributors_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/contributors","subscribers_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/subscribers","subscription_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/subscription","commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/contents/{+path}","compare_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/merges","archive_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/downloads","issues_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues{/number}","pulls_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/labels{/name}","releases_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/releases{/id}","created_at":"2015-01-23T03:50:45Z","updated_at":"2015-02-26T22:00:19Z","pushed_at":"2015-02-26T22:57:39Z","git_url":"git://github.com/MayOneUS/mayday-2.0-backend.git","ssh_url":"git@github.com:MayOneUS/mayday-2.0-backend.git","clone_url":"https://github.com/MayOneUS/mayday-2.0-backend.git","svn_url":"https://github.com/MayOneUS/mayday-2.0-backend","homepage":null,"size":1984,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/11"},"html":{"href":"https://github.com/MayOneUS/mayday-2.0-backend/pull/11"},"issue":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/11"},"comments":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/statuses/c08621655c97364b9b53d9016f6101c53d913eb3"}}}}