{"action":"created","comment":{"url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/comments/174614690","pull_request_review_id":104004392,"id":174614690,"diff_hunk":"@@ -0,0 +1,114 @@\n+class RemoveCmpyNumberFromApplication < ActiveRecord::Migration[5.1]\n+\n+  # Define temp models using both old and new associations\n+  class Company < ApplicationRecord\n+    has_and_belongs_to_many :shf_applications\n+\n+    has_many :company_applications\n+    has_many :shf_applications_tmp, through: :company_applications,\n+                                    source: :shf_application, dependent: :destroy\n+  end\n+\n+  class ShfApplication < ApplicationRecord\n+    has_and_belongs_to_many :companies\n+\n+    has_many :company_applications\n+    has_many :companies_tmp, through: :company_applications,\n+                             source: :company, dependent: :destroy\n+  end\n+\n+  class CompanyApplication < ApplicationRecord\n+    belongs_to :company\n+    belongs_to :shf_application\n+  end\n+\n+  def change","path":"db/migrate/20180219132317_remove_cmpy_number_from_application.rb","position":25,"original_position":25,"commit_id":"a6935374e36faeda515caf9167bf5b232fc212ef","original_commit_id":"a6935374e36faeda515caf9167bf5b232fc212ef","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Cyclomatic complexity for change is too high. [8/6]<br>Method has too many lines. [49/30]","created_at":"2018-03-14T21:23:49Z","updated_at":"2018-03-14T21:23:49Z","html_url":"https://github.com/AgileVentures/shf-project/pull/486#discussion_r174614690","pull_request_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/486","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/comments/174614690"},"html":{"href":"https://github.com/AgileVentures/shf-project/pull/486#discussion_r174614690"},"pull_request":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/486"}}},"pull_request":{"url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/486","id":171818579,"html_url":"https://github.com/AgileVentures/shf-project/pull/486","diff_url":"https://github.com/AgileVentures/shf-project/pull/486.diff","patch_url":"https://github.com/AgileVentures/shf-project/pull/486.patch","issue_url":"https://api.github.com/repos/AgileVentures/shf-project/issues/486","number":486,"state":"open","locked":false,"title":"[WIP] Remove company number from membership application","user":{"login":"patmbolger","id":9968213,"avatar_url":"https://avatars3.githubusercontent.com/u/9968213?v=4","gravatar_id":"","url":"https://api.github.com/users/patmbolger","html_url":"https://github.com/patmbolger","followers_url":"https://api.github.com/users/patmbolger/followers","following_url":"https://api.github.com/users/patmbolger/following{/other_user}","gists_url":"https://api.github.com/users/patmbolger/gists{/gist_id}","starred_url":"https://api.github.com/users/patmbolger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patmbolger/subscriptions","organizations_url":"https://api.github.com/users/patmbolger/orgs","repos_url":"https://api.github.com/users/patmbolger/repos","events_url":"https://api.github.com/users/patmbolger/events{/privacy}","received_events_url":"https://api.github.com/users/patmbolger/received_events","type":"User","site_admin":false},"body":"**Update, Mar 12** Reconfigured the app-edit form (create and update) to use a single data-entry field (for company_number) instead of a selection list showing all existing company_numbers.  This is because we cannot expose company_numbers to the public that are personal numbers (as opposed to actual _organization_ numbers).  The use still has the option of creating a new company if the company does not yet exist.\r\n\r\n**Update, Mar 7** I changed the membership application create/update process to allow a user to either 1) select from an existing list of company numbers, or, if their company does not yet exist, create a new company to associated with the application.  Screenshots shown below.\r\n\r\n**Update, Feb 28** I am rethinking certain aspects of this effort so please hold off on reviewing this PR at this time.\r\n\r\nPT Story: https://www.pivotaltracker.com/story/show/151611254\r\n\r\nThe title of this story is misleading as it actually consists of restructuring the association between an application and companies.  This PR is a follow-on effort to previous efforts, and positions the app for actually implementing, in the UI, the ability to associated a member (via their membership association) with a second, third, etc. company.\r\n\r\nChanges proposed in this pull request:\r\n1.  Drop the attribute `company_number` from ShfApplication.  This was used to keep track of the (single) company associated with an application.  We now use the many<>many association between applications and companies for that.\r\n2. Changed the association between applications and companies from `has_and_belongs_to_many` (HABTM) to `has many ..., through: company_applications` (HMT).  Generally, HMT is preferred over HABTM), since the former involves a real model as the joining association (not just a join table), and as such one can add attribute to that model if needed (this is not needed for this PR, but may be in the future).\r\n3. When an application is created, we now create a corresponding company (or associate the application with an existing company), using the company_number attribute of a company (accessed in the application form via `accepts_nested_attributes_for`).  (this is a departure from prior practice, where we created a company _only_ when the application was accepted).\r\n4. A migration that converts production data from the prior mechanism to this new approach.  The migration is reversible.\r\n5. Added application state `being_destroyed`.  This allows us to destroy all associated companies when an application is destroyed.\r\n\r\nSo, how should one review this sprawling mess of a PR?  I suggest focusing on models and their associations.  Also, take a look at the migration and see if there are any vulnerabilities there.\r\n\r\nAlso, it would be really good if the reviewer would stand up this branch in their local environment, and run the migration and confirm that the data has been correctly migrated.  Then, rollback and confirm the prior data and data structure was restored.\r\n\r\n**Screenshots**\r\n\r\n## User creating application - enter company number or choose to create new company\r\n\r\n<img width=\"614\" alt=\"screen shot 2018-03-12 at 9 07 27 am\" src=\"https://user-images.githubusercontent.com/9968213/37285465-7099e2ce-25d5-11e8-84a7-cd13c25a0f6b.png\">\r\n\r\n## User creating application - create new company - model errors shown\r\n\r\n<img width=\"747\" alt=\"screen shot 2018-03-12 at 9 10 39 am\" src=\"https://user-images.githubusercontent.com/9968213/37285489-7d931298-25d5-11e8-8b4a-2dc48b9554a3.png\">\r\n\r\n\r\n## User has created new company - new company_number auto-entered into form field\r\n\r\n<img width=\"573\" alt=\"screen shot 2018-03-12 at 9 10 59 am\" src=\"https://user-images.githubusercontent.com/9968213/37285500-8679c910-25d5-11e8-88af-0671fe752ebd.png\">\r\n\r\n\r\nReady for review:\r\n@AgileVentures/shf-project-team ","created_at":"2018-02-27T23:49:10Z","updated_at":"2018-03-14T21:23:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5c67852be3194844eae86ecfbf9a8251afdc935f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/486/commits","review_comments_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/486/comments","review_comment_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AgileVentures/shf-project/issues/486/comments","statuses_url":"https://api.github.com/repos/AgileVentures/shf-project/statuses/a6935374e36faeda515caf9167bf5b232fc212ef","head":{"label":"patmbolger:remove-cmpy-number-from-app#151611254","ref":"remove-cmpy-number-from-app#151611254","sha":"a6935374e36faeda515caf9167bf5b232fc212ef","user":{"login":"patmbolger","id":9968213,"avatar_url":"https://avatars3.githubusercontent.com/u/9968213?v=4","gravatar_id":"","url":"https://api.github.com/users/patmbolger","html_url":"https://github.com/patmbolger","followers_url":"https://api.github.com/users/patmbolger/followers","following_url":"https://api.github.com/users/patmbolger/following{/other_user}","gists_url":"https://api.github.com/users/patmbolger/gists{/gist_id}","starred_url":"https://api.github.com/users/patmbolger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patmbolger/subscriptions","organizations_url":"https://api.github.com/users/patmbolger/orgs","repos_url":"https://api.github.com/users/patmbolger/repos","events_url":"https://api.github.com/users/patmbolger/events{/privacy}","received_events_url":"https://api.github.com/users/patmbolger/received_events","type":"User","site_admin":false},"repo":{"id":74601752,"name":"shf-project","full_name":"patmbolger/shf-project","owner":{"login":"patmbolger","id":9968213,"avatar_url":"https://avatars3.githubusercontent.com/u/9968213?v=4","gravatar_id":"","url":"https://api.github.com/users/patmbolger","html_url":"https://github.com/patmbolger","followers_url":"https://api.github.com/users/patmbolger/followers","following_url":"https://api.github.com/users/patmbolger/following{/other_user}","gists_url":"https://api.github.com/users/patmbolger/gists{/gist_id}","starred_url":"https://api.github.com/users/patmbolger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patmbolger/subscriptions","organizations_url":"https://api.github.com/users/patmbolger/orgs","repos_url":"https://api.github.com/users/patmbolger/repos","events_url":"https://api.github.com/users/patmbolger/events{/privacy}","received_events_url":"https://api.github.com/users/patmbolger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/patmbolger/shf-project","description":null,"fork":true,"url":"https://api.github.com/repos/patmbolger/shf-project","forks_url":"https://api.github.com/repos/patmbolger/shf-project/forks","keys_url":"https://api.github.com/repos/patmbolger/shf-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/patmbolger/shf-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/patmbolger/shf-project/teams","hooks_url":"https://api.github.com/repos/patmbolger/shf-project/hooks","issue_events_url":"https://api.github.com/repos/patmbolger/shf-project/issues/events{/number}","events_url":"https://api.github.com/repos/patmbolger/shf-project/events","assignees_url":"https://api.github.com/repos/patmbolger/shf-project/assignees{/user}","branches_url":"https://api.github.com/repos/patmbolger/shf-project/branches{/branch}","tags_url":"https://api.github.com/repos/patmbolger/shf-project/tags","blobs_url":"https://api.github.com/repos/patmbolger/shf-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/patmbolger/shf-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/patmbolger/shf-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/patmbolger/shf-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/patmbolger/shf-project/statuses/{sha}","languages_url":"https://api.github.com/repos/patmbolger/shf-project/languages","stargazers_url":"https://api.github.com/repos/patmbolger/shf-project/stargazers","contributors_url":"https://api.github.com/repos/patmbolger/shf-project/contributors","subscribers_url":"https://api.github.com/repos/patmbolger/shf-project/subscribers","subscription_url":"https://api.github.com/repos/patmbolger/shf-project/subscription","commits_url":"https://api.github.com/repos/patmbolger/shf-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/patmbolger/shf-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/patmbolger/shf-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/patmbolger/shf-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/patmbolger/shf-project/contents/{+path}","compare_url":"https://api.github.com/repos/patmbolger/shf-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/patmbolger/shf-project/merges","archive_url":"https://api.github.com/repos/patmbolger/shf-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/patmbolger/shf-project/downloads","issues_url":"https://api.github.com/repos/patmbolger/shf-project/issues{/number}","pulls_url":"https://api.github.com/repos/patmbolger/shf-project/pulls{/number}","milestones_url":"https://api.github.com/repos/patmbolger/shf-project/milestones{/number}","notifications_url":"https://api.github.com/repos/patmbolger/shf-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/patmbolger/shf-project/labels{/name}","releases_url":"https://api.github.com/repos/patmbolger/shf-project/releases{/id}","deployments_url":"https://api.github.com/repos/patmbolger/shf-project/deployments","created_at":"2016-11-23T18:02:48Z","updated_at":"2017-02-12T13:20:15Z","pushed_at":"2018-03-14T21:23:18Z","git_url":"git://github.com/patmbolger/shf-project.git","ssh_url":"git@github.com:patmbolger/shf-project.git","clone_url":"https://github.com/patmbolger/shf-project.git","svn_url":"https://github.com/patmbolger/shf-project","homepage":null,"size":33565,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"AgileVentures:develop","ref":"develop","sha":"241a78cbe277be7acf8c980ce2e490b382a3da81","user":{"login":"AgileVentures","id":5116968,"avatar_url":"https://avatars0.githubusercontent.com/u/5116968?v=4","gravatar_id":"","url":"https://api.github.com/users/AgileVentures","html_url":"https://github.com/AgileVentures","followers_url":"https://api.github.com/users/AgileVentures/followers","following_url":"https://api.github.com/users/AgileVentures/following{/other_user}","gists_url":"https://api.github.com/users/AgileVentures/gists{/gist_id}","starred_url":"https://api.github.com/users/AgileVentures/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgileVentures/subscriptions","organizations_url":"https://api.github.com/users/AgileVentures/orgs","repos_url":"https://api.github.com/users/AgileVentures/repos","events_url":"https://api.github.com/users/AgileVentures/events{/privacy}","received_events_url":"https://api.github.com/users/AgileVentures/received_events","type":"Organization","site_admin":false},"repo":{"id":71157737,"name":"shf-project","full_name":"AgileVentures/shf-project","owner":{"login":"AgileVentures","id":5116968,"avatar_url":"https://avatars0.githubusercontent.com/u/5116968?v=4","gravatar_id":"","url":"https://api.github.com/users/AgileVentures","html_url":"https://github.com/AgileVentures","followers_url":"https://api.github.com/users/AgileVentures/followers","following_url":"https://api.github.com/users/AgileVentures/following{/other_user}","gists_url":"https://api.github.com/users/AgileVentures/gists{/gist_id}","starred_url":"https://api.github.com/users/AgileVentures/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgileVentures/subscriptions","organizations_url":"https://api.github.com/users/AgileVentures/orgs","repos_url":"https://api.github.com/users/AgileVentures/repos","events_url":"https://api.github.com/users/AgileVentures/events{/privacy}","received_events_url":"https://api.github.com/users/AgileVentures/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AgileVentures/shf-project","description":"Part of the website for and membership management for Sveriges Hundföretagare  (The Swedish Dog  Industry association). A project run with AgileVentures.org","fork":true,"url":"https://api.github.com/repos/AgileVentures/shf-project","forks_url":"https://api.github.com/repos/AgileVentures/shf-project/forks","keys_url":"https://api.github.com/repos/AgileVentures/shf-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AgileVentures/shf-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AgileVentures/shf-project/teams","hooks_url":"https://api.github.com/repos/AgileVentures/shf-project/hooks","issue_events_url":"https://api.github.com/repos/AgileVentures/shf-project/issues/events{/number}","events_url":"https://api.github.com/repos/AgileVentures/shf-project/events","assignees_url":"https://api.github.com/repos/AgileVentures/shf-project/assignees{/user}","branches_url":"https://api.github.com/repos/AgileVentures/shf-project/branches{/branch}","tags_url":"https://api.github.com/repos/AgileVentures/shf-project/tags","blobs_url":"https://api.github.com/repos/AgileVentures/shf-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AgileVentures/shf-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AgileVentures/shf-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/AgileVentures/shf-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AgileVentures/shf-project/statuses/{sha}","languages_url":"https://api.github.com/repos/AgileVentures/shf-project/languages","stargazers_url":"https://api.github.com/repos/AgileVentures/shf-project/stargazers","contributors_url":"https://api.github.com/repos/AgileVentures/shf-project/contributors","subscribers_url":"https://api.github.com/repos/AgileVentures/shf-project/subscribers","subscription_url":"https://api.github.com/repos/AgileVentures/shf-project/subscription","commits_url":"https://api.github.com/repos/AgileVentures/shf-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/AgileVentures/shf-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/AgileVentures/shf-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/AgileVentures/shf-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/AgileVentures/shf-project/contents/{+path}","compare_url":"https://api.github.com/repos/AgileVentures/shf-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AgileVentures/shf-project/merges","archive_url":"https://api.github.com/repos/AgileVentures/shf-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AgileVentures/shf-project/downloads","issues_url":"https://api.github.com/repos/AgileVentures/shf-project/issues{/number}","pulls_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls{/number}","milestones_url":"https://api.github.com/repos/AgileVentures/shf-project/milestones{/number}","notifications_url":"https://api.github.com/repos/AgileVentures/shf-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AgileVentures/shf-project/labels{/name}","releases_url":"https://api.github.com/repos/AgileVentures/shf-project/releases{/id}","deployments_url":"https://api.github.com/repos/AgileVentures/shf-project/deployments","created_at":"2016-10-17T16:18:10Z","updated_at":"2018-02-21T10:22:35Z","pushed_at":"2018-03-14T21:23:20Z","git_url":"git://github.com/AgileVentures/shf-project.git","ssh_url":"git@github.com:AgileVentures/shf-project.git","clone_url":"https://github.com/AgileVentures/shf-project.git","svn_url":"https://github.com/AgileVentures/shf-project","homepage":"","size":32360,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"archived":false,"open_issues_count":9,"license":null,"forks":23,"open_issues":9,"watchers":7,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/486"},"html":{"href":"https://github.com/AgileVentures/shf-project/pull/486"},"issue":{"href":"https://api.github.com/repos/AgileVentures/shf-project/issues/486"},"comments":{"href":"https://api.github.com/repos/AgileVentures/shf-project/issues/486/comments"},"review_comments":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/486/comments"},"review_comment":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/486/commits"},"statuses":{"href":"https://api.github.com/repos/AgileVentures/shf-project/statuses/a6935374e36faeda515caf9167bf5b232fc212ef"}},"author_association":"NONE"}}
{"actor":{"display_login":"houndci-bot"}}