{"action":"created","comment":{"url":"https://api.github.com/repos/lastcat/factory_logger/pulls/comments/32717786","id":32717786,"diff_hunk":"@@ -6,9 +6,37 @@ class Trait < ActiveRecord::Base\n   def self.create_new_trait_and_relation(new_factory, trait)\n     new_trait = Trait.create(name: trait)\n     REDIS.sadd(\"traits\", { name: trait, factory_name: new_factory.name }.to_json)\n-    new_trait_relation = new_factory.trait_relations.build\n-    new_trait_relation.trait = new_trait\n-    new_trait_relation.save\n-    new_trait\n+    TraitRelation.create_new_trait_relation(new_factory, new_trait)\n   end\n+\n+  # TODO: write test\n+  def self.create_new_traits_and_relations(factory, traits_names)\n+    traits_names.each do |trait|\n+      create_new_trait_and_relation(new_factory, trait)\n+    end\n+  end\n+\n+  # TODO: write test\n+  # Create and register only not connected traits to factory.\n+  def self.add_new_traits_and_relations(factory, trait_names)\n+    trait_names.each do |trait|\n+      if same_trait_exist?(trait, factory.name)\n+        TraitRelation.create_new_trait_relation(factory, seach_existing_trait(trait, factory.name))\n+      else\n+        create_new_trait_and_relation(factory, trait)\n+      end\n+    end\n+  end\n+\n+  private\n+  ","path":"app/models/trait.rb","position":31,"original_position":31,"commit_id":"d3ef94776c8b5f63b780cc07bc24c2aab0ffdc62","original_commit_id":"d3ef94776c8b5f63b780cc07bc24c2aab0ffdc62","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Style/TrailingWhitespace: Trailing whitespace detected.","created_at":"2015-06-18T10:45:10Z","updated_at":"2015-06-18T10:45:10Z","html_url":"https://github.com/lastcat/factory_logger/pull/54#discussion_r32717786","pull_request_url":"https://api.github.com/repos/lastcat/factory_logger/pulls/54","_links":{"self":{"href":"https://api.github.com/repos/lastcat/factory_logger/pulls/comments/32717786"},"html":{"href":"https://github.com/lastcat/factory_logger/pull/54#discussion_r32717786"},"pull_request":{"href":"https://api.github.com/repos/lastcat/factory_logger/pulls/54"}}},"pull_request":{"url":"https://api.github.com/repos/lastcat/factory_logger/pulls/54","id":37887447,"html_url":"https://github.com/lastcat/factory_logger/pull/54","diff_url":"https://github.com/lastcat/factory_logger/pull/54.diff","patch_url":"https://github.com/lastcat/factory_logger/pull/54.patch","issue_url":"https://api.github.com/repos/lastcat/factory_logger/issues/54","number":54,"state":"open","locked":false,"title":"refactor create_unique_factory method","user":{"login":"lastcat","id":2026375,"avatar_url":"https://avatars.githubusercontent.com/u/2026375?v=3","gravatar_id":"","url":"https://api.github.com/users/lastcat","html_url":"https://github.com/lastcat","followers_url":"https://api.github.com/users/lastcat/followers","following_url":"https://api.github.com/users/lastcat/following{/other_user}","gists_url":"https://api.github.com/users/lastcat/gists{/gist_id}","starred_url":"https://api.github.com/users/lastcat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lastcat/subscriptions","organizations_url":"https://api.github.com/users/lastcat/orgs","repos_url":"https://api.github.com/users/lastcat/repos","events_url":"https://api.github.com/users/lastcat/events{/privacy}","received_events_url":"https://api.github.com/users/lastcat/received_events","type":"User","site_admin":false},"body":"いろいろ読んだりした結果を適用してみる。主に可読性。","created_at":"2015-06-17T10:45:08Z","updated_at":"2015-06-18T10:45:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"120e56792e2668971de06f0a85cb1a9595c4f4c7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lastcat/factory_logger/pulls/54/commits","review_comments_url":"https://api.github.com/repos/lastcat/factory_logger/pulls/54/comments","review_comment_url":"https://api.github.com/repos/lastcat/factory_logger/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lastcat/factory_logger/issues/54/comments","statuses_url":"https://api.github.com/repos/lastcat/factory_logger/statuses/d3ef94776c8b5f63b780cc07bc24c2aab0ffdc62","head":{"label":"lastcat:refactor","ref":"refactor","sha":"d3ef94776c8b5f63b780cc07bc24c2aab0ffdc62","user":{"login":"lastcat","id":2026375,"avatar_url":"https://avatars.githubusercontent.com/u/2026375?v=3","gravatar_id":"","url":"https://api.github.com/users/lastcat","html_url":"https://github.com/lastcat","followers_url":"https://api.github.com/users/lastcat/followers","following_url":"https://api.github.com/users/lastcat/following{/other_user}","gists_url":"https://api.github.com/users/lastcat/gists{/gist_id}","starred_url":"https://api.github.com/users/lastcat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lastcat/subscriptions","organizations_url":"https://api.github.com/users/lastcat/orgs","repos_url":"https://api.github.com/users/lastcat/repos","events_url":"https://api.github.com/users/lastcat/events{/privacy}","received_events_url":"https://api.github.com/users/lastcat/received_events","type":"User","site_admin":false},"repo":{"id":36217773,"name":"factory_logger","full_name":"lastcat/factory_logger","owner":{"login":"lastcat","id":2026375,"avatar_url":"https://avatars.githubusercontent.com/u/2026375?v=3","gravatar_id":"","url":"https://api.github.com/users/lastcat","html_url":"https://github.com/lastcat","followers_url":"https://api.github.com/users/lastcat/followers","following_url":"https://api.github.com/users/lastcat/following{/other_user}","gists_url":"https://api.github.com/users/lastcat/gists{/gist_id}","starred_url":"https://api.github.com/users/lastcat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lastcat/subscriptions","organizations_url":"https://api.github.com/users/lastcat/orgs","repos_url":"https://api.github.com/users/lastcat/repos","events_url":"https://api.github.com/users/lastcat/events{/privacy}","received_events_url":"https://api.github.com/users/lastcat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lastcat/factory_logger","description":"This is gem logging factory_girl execution info.","fork":false,"url":"https://api.github.com/repos/lastcat/factory_logger","forks_url":"https://api.github.com/repos/lastcat/factory_logger/forks","keys_url":"https://api.github.com/repos/lastcat/factory_logger/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lastcat/factory_logger/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lastcat/factory_logger/teams","hooks_url":"https://api.github.com/repos/lastcat/factory_logger/hooks","issue_events_url":"https://api.github.com/repos/lastcat/factory_logger/issues/events{/number}","events_url":"https://api.github.com/repos/lastcat/factory_logger/events","assignees_url":"https://api.github.com/repos/lastcat/factory_logger/assignees{/user}","branches_url":"https://api.github.com/repos/lastcat/factory_logger/branches{/branch}","tags_url":"https://api.github.com/repos/lastcat/factory_logger/tags","blobs_url":"https://api.github.com/repos/lastcat/factory_logger/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lastcat/factory_logger/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lastcat/factory_logger/git/refs{/sha}","trees_url":"https://api.github.com/repos/lastcat/factory_logger/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lastcat/factory_logger/statuses/{sha}","languages_url":"https://api.github.com/repos/lastcat/factory_logger/languages","stargazers_url":"https://api.github.com/repos/lastcat/factory_logger/stargazers","contributors_url":"https://api.github.com/repos/lastcat/factory_logger/contributors","subscribers_url":"https://api.github.com/repos/lastcat/factory_logger/subscribers","subscription_url":"https://api.github.com/repos/lastcat/factory_logger/subscription","commits_url":"https://api.github.com/repos/lastcat/factory_logger/commits{/sha}","git_commits_url":"https://api.github.com/repos/lastcat/factory_logger/git/commits{/sha}","comments_url":"https://api.github.com/repos/lastcat/factory_logger/comments{/number}","issue_comment_url":"https://api.github.com/repos/lastcat/factory_logger/issues/comments{/number}","contents_url":"https://api.github.com/repos/lastcat/factory_logger/contents/{+path}","compare_url":"https://api.github.com/repos/lastcat/factory_logger/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lastcat/factory_logger/merges","archive_url":"https://api.github.com/repos/lastcat/factory_logger/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lastcat/factory_logger/downloads","issues_url":"https://api.github.com/repos/lastcat/factory_logger/issues{/number}","pulls_url":"https://api.github.com/repos/lastcat/factory_logger/pulls{/number}","milestones_url":"https://api.github.com/repos/lastcat/factory_logger/milestones{/number}","notifications_url":"https://api.github.com/repos/lastcat/factory_logger/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lastcat/factory_logger/labels{/name}","releases_url":"https://api.github.com/repos/lastcat/factory_logger/releases{/id}","created_at":"2015-05-25T07:52:39Z","updated_at":"2015-05-25T07:53:34Z","pushed_at":"2015-06-18T10:45:02Z","git_url":"git://github.com/lastcat/factory_logger.git","ssh_url":"git@github.com:lastcat/factory_logger.git","clone_url":"https://github.com/lastcat/factory_logger.git","svn_url":"https://github.com/lastcat/factory_logger","homepage":null,"size":1564,"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":7,"forks":0,"open_issues":7,"watchers":0,"default_branch":"master"}},"base":{"label":"lastcat:master","ref":"master","sha":"6939d863145a47fd9b428e6bc5f93857a1b0b5e5","user":{"login":"lastcat","id":2026375,"avatar_url":"https://avatars.githubusercontent.com/u/2026375?v=3","gravatar_id":"","url":"https://api.github.com/users/lastcat","html_url":"https://github.com/lastcat","followers_url":"https://api.github.com/users/lastcat/followers","following_url":"https://api.github.com/users/lastcat/following{/other_user}","gists_url":"https://api.github.com/users/lastcat/gists{/gist_id}","starred_url":"https://api.github.com/users/lastcat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lastcat/subscriptions","organizations_url":"https://api.github.com/users/lastcat/orgs","repos_url":"https://api.github.com/users/lastcat/repos","events_url":"https://api.github.com/users/lastcat/events{/privacy}","received_events_url":"https://api.github.com/users/lastcat/received_events","type":"User","site_admin":false},"repo":{"id":36217773,"name":"factory_logger","full_name":"lastcat/factory_logger","owner":{"login":"lastcat","id":2026375,"avatar_url":"https://avatars.githubusercontent.com/u/2026375?v=3","gravatar_id":"","url":"https://api.github.com/users/lastcat","html_url":"https://github.com/lastcat","followers_url":"https://api.github.com/users/lastcat/followers","following_url":"https://api.github.com/users/lastcat/following{/other_user}","gists_url":"https://api.github.com/users/lastcat/gists{/gist_id}","starred_url":"https://api.github.com/users/lastcat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lastcat/subscriptions","organizations_url":"https://api.github.com/users/lastcat/orgs","repos_url":"https://api.github.com/users/lastcat/repos","events_url":"https://api.github.com/users/lastcat/events{/privacy}","received_events_url":"https://api.github.com/users/lastcat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lastcat/factory_logger","description":"This is gem logging factory_girl execution info.","fork":false,"url":"https://api.github.com/repos/lastcat/factory_logger","forks_url":"https://api.github.com/repos/lastcat/factory_logger/forks","keys_url":"https://api.github.com/repos/lastcat/factory_logger/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lastcat/factory_logger/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lastcat/factory_logger/teams","hooks_url":"https://api.github.com/repos/lastcat/factory_logger/hooks","issue_events_url":"https://api.github.com/repos/lastcat/factory_logger/issues/events{/number}","events_url":"https://api.github.com/repos/lastcat/factory_logger/events","assignees_url":"https://api.github.com/repos/lastcat/factory_logger/assignees{/user}","branches_url":"https://api.github.com/repos/lastcat/factory_logger/branches{/branch}","tags_url":"https://api.github.com/repos/lastcat/factory_logger/tags","blobs_url":"https://api.github.com/repos/lastcat/factory_logger/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lastcat/factory_logger/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lastcat/factory_logger/git/refs{/sha}","trees_url":"https://api.github.com/repos/lastcat/factory_logger/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lastcat/factory_logger/statuses/{sha}","languages_url":"https://api.github.com/repos/lastcat/factory_logger/languages","stargazers_url":"https://api.github.com/repos/lastcat/factory_logger/stargazers","contributors_url":"https://api.github.com/repos/lastcat/factory_logger/contributors","subscribers_url":"https://api.github.com/repos/lastcat/factory_logger/subscribers","subscription_url":"https://api.github.com/repos/lastcat/factory_logger/subscription","commits_url":"https://api.github.com/repos/lastcat/factory_logger/commits{/sha}","git_commits_url":"https://api.github.com/repos/lastcat/factory_logger/git/commits{/sha}","comments_url":"https://api.github.com/repos/lastcat/factory_logger/comments{/number}","issue_comment_url":"https://api.github.com/repos/lastcat/factory_logger/issues/comments{/number}","contents_url":"https://api.github.com/repos/lastcat/factory_logger/contents/{+path}","compare_url":"https://api.github.com/repos/lastcat/factory_logger/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lastcat/factory_logger/merges","archive_url":"https://api.github.com/repos/lastcat/factory_logger/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lastcat/factory_logger/downloads","issues_url":"https://api.github.com/repos/lastcat/factory_logger/issues{/number}","pulls_url":"https://api.github.com/repos/lastcat/factory_logger/pulls{/number}","milestones_url":"https://api.github.com/repos/lastcat/factory_logger/milestones{/number}","notifications_url":"https://api.github.com/repos/lastcat/factory_logger/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lastcat/factory_logger/labels{/name}","releases_url":"https://api.github.com/repos/lastcat/factory_logger/releases{/id}","created_at":"2015-05-25T07:52:39Z","updated_at":"2015-05-25T07:53:34Z","pushed_at":"2015-06-18T10:45:02Z","git_url":"git://github.com/lastcat/factory_logger.git","ssh_url":"git@github.com:lastcat/factory_logger.git","clone_url":"https://github.com/lastcat/factory_logger.git","svn_url":"https://github.com/lastcat/factory_logger","homepage":null,"size":1564,"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":7,"forks":0,"open_issues":7,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lastcat/factory_logger/pulls/54"},"html":{"href":"https://github.com/lastcat/factory_logger/pull/54"},"issue":{"href":"https://api.github.com/repos/lastcat/factory_logger/issues/54"},"comments":{"href":"https://api.github.com/repos/lastcat/factory_logger/issues/54/comments"},"review_comments":{"href":"https://api.github.com/repos/lastcat/factory_logger/pulls/54/comments"},"review_comment":{"href":"https://api.github.com/repos/lastcat/factory_logger/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lastcat/factory_logger/pulls/54/commits"},"statuses":{"href":"https://api.github.com/repos/lastcat/factory_logger/statuses/d3ef94776c8b5f63b780cc07bc24c2aab0ffdc62"}}}}