{"action":"opened","number":250,"pull_request":{"url":"https://api.github.com/repos/redding/mr/pulls/250","id":110902172,"html_url":"https://github.com/redding/mr/pull/250","diff_url":"https://github.com/redding/mr/pull/250.diff","patch_url":"https://github.com/redding/mr/pull/250.patch","issue_url":"https://api.github.com/repos/redding/mr/issues/250","number":250,"state":"open","locked":false,"title":"Add `default_association` to factories","user":{"login":"jcredding","id":85966,"avatar_url":"https://avatars3.githubusercontent.com/u/85966?v=3","gravatar_id":"","url":"https://api.github.com/users/jcredding","html_url":"https://github.com/jcredding","followers_url":"https://api.github.com/users/jcredding/followers","following_url":"https://api.github.com/users/jcredding/following{/other_user}","gists_url":"https://api.github.com/users/jcredding/gists{/gist_id}","starred_url":"https://api.github.com/users/jcredding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcredding/subscriptions","organizations_url":"https://api.github.com/users/jcredding/orgs","repos_url":"https://api.github.com/users/jcredding/repos","events_url":"https://api.github.com/users/jcredding/events{/privacy}","received_events_url":"https://api.github.com/users/jcredding/received_events","type":"User","site_admin":false},"body":"This adds a `default_association` method to model and record\r\nfactories that will allow them to configure the factory an\r\nassociation should use when its built.\r\n\r\nThis updates the `AssociationFactoryLookup` to now have logic for\r\nadding factories for an association. This is needed so users can\r\nconfigure factories for associations when building a factory. This\r\nadds an `add_factory` method that takes an owner record class,\r\nassociation name and associated factory. When an associated factory\r\nis added the lookup adds it as a default factory, copies its\r\nconfigured factories, and then adds it as a factory for the\r\nassociation (the owner record class, association name, and\r\nassociated record class). If the association is a polymorphic\r\nassociation then the lokup will also add the factory for a\r\n`nil` associated record class so the key is only a owner record\r\nclass and association name. This will allow polymorphic\r\nassociations to be built without the foreign type attribute\r\nbeing set as long as they have association factories configured.\r\n\r\nWhen adding a default factory, the lookup will only register it if\r\nit doesn't already have a default factory for the record class.\r\nThis keeps the lookup from changing its default factory over and\r\nover as factories are added.\r\n\r\nWhen the lookup copies factories from another lookup it copies\r\nboth the default factories and association factories. The\r\ndefault factories are added the same as above where it will only\r\ncopy defaults if it doesn't already have one. Association\r\nfactories are merged so if the lookup already has a factory\r\nconfigured for an association then its existing factories are\r\nunioned with the new factories. This should only occur in circular\r\nassociation chains or when the same model is encountered multiple\r\ntimes (like a user model for example).\r\n\r\nThis also includes a minor cleanup to the record stack logic. It\r\ndoesn't need to manually raise a no record class error and can\r\nlet the association factory lookup when it tries to build a\r\nrecord/model for the association.\r\n\r\n@kellyredding - Ready for review.","created_at":"2017-03-15T17:39:48Z","updated_at":"2017-03-15T17:39:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/redding/mr/pulls/250/commits","review_comments_url":"https://api.github.com/repos/redding/mr/pulls/250/comments","review_comment_url":"https://api.github.com/repos/redding/mr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/redding/mr/issues/250/comments","statuses_url":"https://api.github.com/repos/redding/mr/statuses/58e8a5c968d1ef72e31790040a33d1788533c982","head":{"label":"redding:jcr-add-default-association-to-factories","ref":"jcr-add-default-association-to-factories","sha":"58e8a5c968d1ef72e31790040a33d1788533c982","user":{"login":"redding","id":2427810,"avatar_url":"https://avatars2.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"repo":{"id":9087217,"name":"mr","full_name":"redding/mr","owner":{"login":"redding","id":2427810,"avatar_url":"https://avatars2.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/redding/mr","description":"Model-record pattern","fork":false,"url":"https://api.github.com/repos/redding/mr","forks_url":"https://api.github.com/repos/redding/mr/forks","keys_url":"https://api.github.com/repos/redding/mr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/redding/mr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/redding/mr/teams","hooks_url":"https://api.github.com/repos/redding/mr/hooks","issue_events_url":"https://api.github.com/repos/redding/mr/issues/events{/number}","events_url":"https://api.github.com/repos/redding/mr/events","assignees_url":"https://api.github.com/repos/redding/mr/assignees{/user}","branches_url":"https://api.github.com/repos/redding/mr/branches{/branch}","tags_url":"https://api.github.com/repos/redding/mr/tags","blobs_url":"https://api.github.com/repos/redding/mr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/redding/mr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/redding/mr/git/refs{/sha}","trees_url":"https://api.github.com/repos/redding/mr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/redding/mr/statuses/{sha}","languages_url":"https://api.github.com/repos/redding/mr/languages","stargazers_url":"https://api.github.com/repos/redding/mr/stargazers","contributors_url":"https://api.github.com/repos/redding/mr/contributors","subscribers_url":"https://api.github.com/repos/redding/mr/subscribers","subscription_url":"https://api.github.com/repos/redding/mr/subscription","commits_url":"https://api.github.com/repos/redding/mr/commits{/sha}","git_commits_url":"https://api.github.com/repos/redding/mr/git/commits{/sha}","comments_url":"https://api.github.com/repos/redding/mr/comments{/number}","issue_comment_url":"https://api.github.com/repos/redding/mr/issues/comments{/number}","contents_url":"https://api.github.com/repos/redding/mr/contents/{+path}","compare_url":"https://api.github.com/repos/redding/mr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/redding/mr/merges","archive_url":"https://api.github.com/repos/redding/mr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/redding/mr/downloads","issues_url":"https://api.github.com/repos/redding/mr/issues{/number}","pulls_url":"https://api.github.com/repos/redding/mr/pulls{/number}","milestones_url":"https://api.github.com/repos/redding/mr/milestones{/number}","notifications_url":"https://api.github.com/repos/redding/mr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/redding/mr/labels{/name}","releases_url":"https://api.github.com/repos/redding/mr/releases{/id}","deployments_url":"https://api.github.com/repos/redding/mr/deployments","created_at":"2013-03-28T21:56:05Z","updated_at":"2016-03-30T22:01:30Z","pushed_at":"2017-03-15T17:39:30Z","git_url":"git://github.com/redding/mr.git","ssh_url":"git@github.com:redding/mr.git","clone_url":"https://github.com/redding/mr.git","svn_url":"https://github.com/redding/mr","homepage":"","size":583,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":12,"forks":1,"open_issues":12,"watchers":1,"default_branch":"master"}},"base":{"label":"redding:feature-moar-better-factories","ref":"feature-moar-better-factories","sha":"e89de7c4226da7c4766d6f1dfd42cb8beb2b9fc0","user":{"login":"redding","id":2427810,"avatar_url":"https://avatars2.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"repo":{"id":9087217,"name":"mr","full_name":"redding/mr","owner":{"login":"redding","id":2427810,"avatar_url":"https://avatars2.githubusercontent.com/u/2427810?v=3","gravatar_id":"","url":"https://api.github.com/users/redding","html_url":"https://github.com/redding","followers_url":"https://api.github.com/users/redding/followers","following_url":"https://api.github.com/users/redding/following{/other_user}","gists_url":"https://api.github.com/users/redding/gists{/gist_id}","starred_url":"https://api.github.com/users/redding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redding/subscriptions","organizations_url":"https://api.github.com/users/redding/orgs","repos_url":"https://api.github.com/users/redding/repos","events_url":"https://api.github.com/users/redding/events{/privacy}","received_events_url":"https://api.github.com/users/redding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/redding/mr","description":"Model-record pattern","fork":false,"url":"https://api.github.com/repos/redding/mr","forks_url":"https://api.github.com/repos/redding/mr/forks","keys_url":"https://api.github.com/repos/redding/mr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/redding/mr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/redding/mr/teams","hooks_url":"https://api.github.com/repos/redding/mr/hooks","issue_events_url":"https://api.github.com/repos/redding/mr/issues/events{/number}","events_url":"https://api.github.com/repos/redding/mr/events","assignees_url":"https://api.github.com/repos/redding/mr/assignees{/user}","branches_url":"https://api.github.com/repos/redding/mr/branches{/branch}","tags_url":"https://api.github.com/repos/redding/mr/tags","blobs_url":"https://api.github.com/repos/redding/mr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/redding/mr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/redding/mr/git/refs{/sha}","trees_url":"https://api.github.com/repos/redding/mr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/redding/mr/statuses/{sha}","languages_url":"https://api.github.com/repos/redding/mr/languages","stargazers_url":"https://api.github.com/repos/redding/mr/stargazers","contributors_url":"https://api.github.com/repos/redding/mr/contributors","subscribers_url":"https://api.github.com/repos/redding/mr/subscribers","subscription_url":"https://api.github.com/repos/redding/mr/subscription","commits_url":"https://api.github.com/repos/redding/mr/commits{/sha}","git_commits_url":"https://api.github.com/repos/redding/mr/git/commits{/sha}","comments_url":"https://api.github.com/repos/redding/mr/comments{/number}","issue_comment_url":"https://api.github.com/repos/redding/mr/issues/comments{/number}","contents_url":"https://api.github.com/repos/redding/mr/contents/{+path}","compare_url":"https://api.github.com/repos/redding/mr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/redding/mr/merges","archive_url":"https://api.github.com/repos/redding/mr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/redding/mr/downloads","issues_url":"https://api.github.com/repos/redding/mr/issues{/number}","pulls_url":"https://api.github.com/repos/redding/mr/pulls{/number}","milestones_url":"https://api.github.com/repos/redding/mr/milestones{/number}","notifications_url":"https://api.github.com/repos/redding/mr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/redding/mr/labels{/name}","releases_url":"https://api.github.com/repos/redding/mr/releases{/id}","deployments_url":"https://api.github.com/repos/redding/mr/deployments","created_at":"2013-03-28T21:56:05Z","updated_at":"2016-03-30T22:01:30Z","pushed_at":"2017-03-15T17:39:30Z","git_url":"git://github.com/redding/mr.git","ssh_url":"git@github.com:redding/mr.git","clone_url":"https://github.com/redding/mr.git","svn_url":"https://github.com/redding/mr","homepage":"","size":583,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":12,"forks":1,"open_issues":12,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/redding/mr/pulls/250"},"html":{"href":"https://github.com/redding/mr/pull/250"},"issue":{"href":"https://api.github.com/repos/redding/mr/issues/250"},"comments":{"href":"https://api.github.com/repos/redding/mr/issues/250/comments"},"review_comments":{"href":"https://api.github.com/repos/redding/mr/pulls/250/comments"},"review_comment":{"href":"https://api.github.com/repos/redding/mr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/redding/mr/pulls/250/commits"},"statuses":{"href":"https://api.github.com/repos/redding/mr/statuses/58e8a5c968d1ef72e31790040a33d1788533c982"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":367,"deletions":76,"changed_files":11}}
{"actor":{"display_login":"jcredding"}}