{"action":"created","comment":{"url":"https://api.github.com/repos/Katello/katello/pulls/comments/67224992","id":67224992,"diff_hunk":"@@ -3,21 +3,29 @@ module Validators\n     class ContentViewPuppetModuleValidator < ActiveModel::Validator\n       def validate(record)\n         if record.uuid.blank? && (record.name.blank? || record.author.blank?)\n-          invalid_parameters = _(\"Invalid puppet module parameters specified.  Either 'uuid' or 'name' and 'author' must be specified.\")\n-          record.errors[:base] << invalid_parameters\n-          return\n-        end\n-\n-        if record.name && record.author\n-          # validate that a puppet module exists with this name+author\n-          unless PuppetModule\n-                  .in_repositories(record.content_view.puppet_repos)\n-                  .where(:name => record.name, :author => record.author).present?\n-\n-            invalid_parameters = _(\"Puppet Module with name='%{name}' and author='%{author}' does not exist\") %\n-                { :name => record.name, :author => record.author }\n+          record.errors[:base] << _(\"Invalid puppet module parameters specified. \\\n+                                    Either 'uuid' or 'name' and 'author' must be specified.\")\n+        elsif record.name && record.author &&\n+          !PuppetModule.exists?(name: record.name, author: record.author)\n+          record.errors[:base] << _(\"Puppet Module with name='%{name}' and author='%{author}' does\\\n+                                    not exist\") % { name: record.name, author: record.author }\n+        elsif record.uuid && !PuppetModule.exists?(uuid: record.uuid)\n+          record.errors[:base] << _(\"Puppet Module with uuid='%{uuid}' does not\\\n+                                    exist\") % { uuid: record.uuid }\n+        else\n+          puppet_modules = PuppetModule.where(\n+            if record.uuid.blank?\n+              { name: record.name, author: record.author }\n+            else\n+              { uuid: record.uuid }\n+            end","path":"app/lib/katello/validators/content_view_puppet_module_validator.rb","position":32,"original_position":32,"commit_id":"9b0db76f98b566e1e99ee2a1724d6bcd96702aba","original_commit_id":"9b0db76f98b566e1e99ee2a1724d6bcd96702aba","user":{"login":"akofink","id":761923,"avatar_url":"https://avatars.githubusercontent.com/u/761923?v=3","gravatar_id":"","url":"https://api.github.com/users/akofink","html_url":"https://github.com/akofink","followers_url":"https://api.github.com/users/akofink/followers","following_url":"https://api.github.com/users/akofink/following{/other_user}","gists_url":"https://api.github.com/users/akofink/gists{/gist_id}","starred_url":"https://api.github.com/users/akofink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akofink/subscriptions","organizations_url":"https://api.github.com/users/akofink/orgs","repos_url":"https://api.github.com/users/akofink/repos","events_url":"https://api.github.com/users/akofink/events{/privacy}","received_events_url":"https://api.github.com/users/akofink/received_events","type":"User","site_admin":false},"body":"```ruby\r\nputs(if :i_am_right\r\n  \"of course it works\"\r\nelse\r\n  \"no way it works\"\r\nend)\r\nof course it works\r\n=> nil\r\n```","created_at":"2016-06-15T19:02:48Z","updated_at":"2016-06-15T19:02:48Z","html_url":"https://github.com/Katello/katello/pull/6093#discussion_r67224992","pull_request_url":"https://api.github.com/repos/Katello/katello/pulls/6093","_links":{"self":{"href":"https://api.github.com/repos/Katello/katello/pulls/comments/67224992"},"html":{"href":"https://github.com/Katello/katello/pull/6093#discussion_r67224992"},"pull_request":{"href":"https://api.github.com/repos/Katello/katello/pulls/6093"}}},"pull_request":{"url":"https://api.github.com/repos/Katello/katello/pulls/6093","id":72191765,"html_url":"https://github.com/Katello/katello/pull/6093","diff_url":"https://github.com/Katello/katello/pull/6093.diff","patch_url":"https://github.com/Katello/katello/pull/6093.patch","issue_url":"https://api.github.com/repos/Katello/katello/issues/6093","number":6093,"state":"open","locked":false,"title":"Fixes #15177 - Add validation to content view...","user":{"login":"akofink","id":761923,"avatar_url":"https://avatars.githubusercontent.com/u/761923?v=3","gravatar_id":"","url":"https://api.github.com/users/akofink","html_url":"https://github.com/akofink","followers_url":"https://api.github.com/users/akofink/followers","following_url":"https://api.github.com/users/akofink/following{/other_user}","gists_url":"https://api.github.com/users/akofink/gists{/gist_id}","starred_url":"https://api.github.com/users/akofink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akofink/subscriptions","organizations_url":"https://api.github.com/users/akofink/orgs","repos_url":"https://api.github.com/users/akofink/repos","events_url":"https://api.github.com/users/akofink/events{/privacy}","received_events_url":"https://api.github.com/users/akofink/received_events","type":"User","site_admin":false},"body":"Add validation to content view puppet module to make sure a valid content view with that same uuid\r\nor name/author combination exists. In addition, the user may use the\r\npuppet_module id, which will set the uuid of the\r\ncontent_view_puppet_module to the same as the puppet_module.\r\n\r\nIf a content view is specified, the puppet module must belong to a\r\nrepository that belongs to the same organization as the content view.\r\n\r\nAn edge case: If two puppet modules with identical names and authors but\r\ntwo different organizations are used to validate a content view puppet\r\nmodule whose content view organization is one of the two organizations,\r\nvalidation should pass.","created_at":"2016-06-01T14:34:30Z","updated_at":"2016-06-15T19:02:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"392f69a7da63b8d8588c6680e716ea2a6da20a49","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Katello/katello/pulls/6093/commits","review_comments_url":"https://api.github.com/repos/Katello/katello/pulls/6093/comments","review_comment_url":"https://api.github.com/repos/Katello/katello/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Katello/katello/issues/6093/comments","statuses_url":"https://api.github.com/repos/Katello/katello/statuses/9b0db76f98b566e1e99ee2a1724d6bcd96702aba","head":{"label":"akofink:15177","ref":"15177","sha":"9b0db76f98b566e1e99ee2a1724d6bcd96702aba","user":{"login":"akofink","id":761923,"avatar_url":"https://avatars.githubusercontent.com/u/761923?v=3","gravatar_id":"","url":"https://api.github.com/users/akofink","html_url":"https://github.com/akofink","followers_url":"https://api.github.com/users/akofink/followers","following_url":"https://api.github.com/users/akofink/following{/other_user}","gists_url":"https://api.github.com/users/akofink/gists{/gist_id}","starred_url":"https://api.github.com/users/akofink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akofink/subscriptions","organizations_url":"https://api.github.com/users/akofink/orgs","repos_url":"https://api.github.com/users/akofink/repos","events_url":"https://api.github.com/users/akofink/events{/privacy}","received_events_url":"https://api.github.com/users/akofink/received_events","type":"User","site_admin":false},"repo":{"id":14893381,"name":"katello","full_name":"akofink/katello","owner":{"login":"akofink","id":761923,"avatar_url":"https://avatars.githubusercontent.com/u/761923?v=3","gravatar_id":"","url":"https://api.github.com/users/akofink","html_url":"https://github.com/akofink","followers_url":"https://api.github.com/users/akofink/followers","following_url":"https://api.github.com/users/akofink/following{/other_user}","gists_url":"https://api.github.com/users/akofink/gists{/gist_id}","starred_url":"https://api.github.com/users/akofink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akofink/subscriptions","organizations_url":"https://api.github.com/users/akofink/orgs","repos_url":"https://api.github.com/users/akofink/repos","events_url":"https://api.github.com/users/akofink/events{/privacy}","received_events_url":"https://api.github.com/users/akofink/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/akofink/katello","description":"Katello integrates open source systems management tools into a single solution for controlling the lifecycle of your machines.","fork":true,"url":"https://api.github.com/repos/akofink/katello","forks_url":"https://api.github.com/repos/akofink/katello/forks","keys_url":"https://api.github.com/repos/akofink/katello/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akofink/katello/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akofink/katello/teams","hooks_url":"https://api.github.com/repos/akofink/katello/hooks","issue_events_url":"https://api.github.com/repos/akofink/katello/issues/events{/number}","events_url":"https://api.github.com/repos/akofink/katello/events","assignees_url":"https://api.github.com/repos/akofink/katello/assignees{/user}","branches_url":"https://api.github.com/repos/akofink/katello/branches{/branch}","tags_url":"https://api.github.com/repos/akofink/katello/tags","blobs_url":"https://api.github.com/repos/akofink/katello/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akofink/katello/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akofink/katello/git/refs{/sha}","trees_url":"https://api.github.com/repos/akofink/katello/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akofink/katello/statuses/{sha}","languages_url":"https://api.github.com/repos/akofink/katello/languages","stargazers_url":"https://api.github.com/repos/akofink/katello/stargazers","contributors_url":"https://api.github.com/repos/akofink/katello/contributors","subscribers_url":"https://api.github.com/repos/akofink/katello/subscribers","subscription_url":"https://api.github.com/repos/akofink/katello/subscription","commits_url":"https://api.github.com/repos/akofink/katello/commits{/sha}","git_commits_url":"https://api.github.com/repos/akofink/katello/git/commits{/sha}","comments_url":"https://api.github.com/repos/akofink/katello/comments{/number}","issue_comment_url":"https://api.github.com/repos/akofink/katello/issues/comments{/number}","contents_url":"https://api.github.com/repos/akofink/katello/contents/{+path}","compare_url":"https://api.github.com/repos/akofink/katello/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akofink/katello/merges","archive_url":"https://api.github.com/repos/akofink/katello/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akofink/katello/downloads","issues_url":"https://api.github.com/repos/akofink/katello/issues{/number}","pulls_url":"https://api.github.com/repos/akofink/katello/pulls{/number}","milestones_url":"https://api.github.com/repos/akofink/katello/milestones{/number}","notifications_url":"https://api.github.com/repos/akofink/katello/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akofink/katello/labels{/name}","releases_url":"https://api.github.com/repos/akofink/katello/releases{/id}","deployments_url":"https://api.github.com/repos/akofink/katello/deployments","created_at":"2013-12-03T12:48:48Z","updated_at":"2016-03-11T21:20:26Z","pushed_at":"2016-06-15T17:53:45Z","git_url":"git://github.com/akofink/katello.git","ssh_url":"git@github.com:akofink/katello.git","clone_url":"https://github.com/akofink/katello.git","svn_url":"https://github.com/akofink/katello","homepage":"katello.org","size":91074,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Katello:master","ref":"master","sha":"e28756464517ca7ad971d6669010cd69dfdaf575","user":{"login":"Katello","id":1316386,"avatar_url":"https://avatars.githubusercontent.com/u/1316386?v=3","gravatar_id":"","url":"https://api.github.com/users/Katello","html_url":"https://github.com/Katello","followers_url":"https://api.github.com/users/Katello/followers","following_url":"https://api.github.com/users/Katello/following{/other_user}","gists_url":"https://api.github.com/users/Katello/gists{/gist_id}","starred_url":"https://api.github.com/users/Katello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Katello/subscriptions","organizations_url":"https://api.github.com/users/Katello/orgs","repos_url":"https://api.github.com/users/Katello/repos","events_url":"https://api.github.com/users/Katello/events{/privacy}","received_events_url":"https://api.github.com/users/Katello/received_events","type":"Organization","site_admin":false},"repo":{"id":4007018,"name":"katello","full_name":"Katello/katello","owner":{"login":"Katello","id":1316386,"avatar_url":"https://avatars.githubusercontent.com/u/1316386?v=3","gravatar_id":"","url":"https://api.github.com/users/Katello","html_url":"https://github.com/Katello","followers_url":"https://api.github.com/users/Katello/followers","following_url":"https://api.github.com/users/Katello/following{/other_user}","gists_url":"https://api.github.com/users/Katello/gists{/gist_id}","starred_url":"https://api.github.com/users/Katello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Katello/subscriptions","organizations_url":"https://api.github.com/users/Katello/orgs","repos_url":"https://api.github.com/users/Katello/repos","events_url":"https://api.github.com/users/Katello/events{/privacy}","received_events_url":"https://api.github.com/users/Katello/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Katello/katello","description":"Katello integrates open source systems management tools into a single solution for controlling the lifecycle of your machines.","fork":false,"url":"https://api.github.com/repos/Katello/katello","forks_url":"https://api.github.com/repos/Katello/katello/forks","keys_url":"https://api.github.com/repos/Katello/katello/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Katello/katello/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Katello/katello/teams","hooks_url":"https://api.github.com/repos/Katello/katello/hooks","issue_events_url":"https://api.github.com/repos/Katello/katello/issues/events{/number}","events_url":"https://api.github.com/repos/Katello/katello/events","assignees_url":"https://api.github.com/repos/Katello/katello/assignees{/user}","branches_url":"https://api.github.com/repos/Katello/katello/branches{/branch}","tags_url":"https://api.github.com/repos/Katello/katello/tags","blobs_url":"https://api.github.com/repos/Katello/katello/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Katello/katello/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Katello/katello/git/refs{/sha}","trees_url":"https://api.github.com/repos/Katello/katello/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Katello/katello/statuses/{sha}","languages_url":"https://api.github.com/repos/Katello/katello/languages","stargazers_url":"https://api.github.com/repos/Katello/katello/stargazers","contributors_url":"https://api.github.com/repos/Katello/katello/contributors","subscribers_url":"https://api.github.com/repos/Katello/katello/subscribers","subscription_url":"https://api.github.com/repos/Katello/katello/subscription","commits_url":"https://api.github.com/repos/Katello/katello/commits{/sha}","git_commits_url":"https://api.github.com/repos/Katello/katello/git/commits{/sha}","comments_url":"https://api.github.com/repos/Katello/katello/comments{/number}","issue_comment_url":"https://api.github.com/repos/Katello/katello/issues/comments{/number}","contents_url":"https://api.github.com/repos/Katello/katello/contents/{+path}","compare_url":"https://api.github.com/repos/Katello/katello/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Katello/katello/merges","archive_url":"https://api.github.com/repos/Katello/katello/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Katello/katello/downloads","issues_url":"https://api.github.com/repos/Katello/katello/issues{/number}","pulls_url":"https://api.github.com/repos/Katello/katello/pulls{/number}","milestones_url":"https://api.github.com/repos/Katello/katello/milestones{/number}","notifications_url":"https://api.github.com/repos/Katello/katello/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Katello/katello/labels{/name}","releases_url":"https://api.github.com/repos/Katello/katello/releases{/id}","deployments_url":"https://api.github.com/repos/Katello/katello/deployments","created_at":"2012-04-12T16:59:08Z","updated_at":"2016-06-03T07:46:36Z","pushed_at":"2016-06-15T18:14:50Z","git_url":"git://github.com/Katello/katello.git","ssh_url":"git@github.com:Katello/katello.git","clone_url":"https://github.com/Katello/katello.git","svn_url":"https://github.com/Katello/katello","homepage":"katello.org","size":127791,"stargazers_count":186,"watchers_count":186,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":127,"mirror_url":null,"open_issues_count":99,"forks":127,"open_issues":99,"watchers":186,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Katello/katello/pulls/6093"},"html":{"href":"https://github.com/Katello/katello/pull/6093"},"issue":{"href":"https://api.github.com/repos/Katello/katello/issues/6093"},"comments":{"href":"https://api.github.com/repos/Katello/katello/issues/6093/comments"},"review_comments":{"href":"https://api.github.com/repos/Katello/katello/pulls/6093/comments"},"review_comment":{"href":"https://api.github.com/repos/Katello/katello/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Katello/katello/pulls/6093/commits"},"statuses":{"href":"https://api.github.com/repos/Katello/katello/statuses/9b0db76f98b566e1e99ee2a1724d6bcd96702aba"}}}}
{"actor":{"display_login":"akofink"}}