{"action":"created","comment":{"url":"https://api.github.com/repos/crossroads/api.goodcity/pulls/comments/112180841","pull_request_review_id":33474623,"id":112180841,"diff_hunk":"@@ -14,84 +14,144 @@ namespace :demo do\n     task load: :environment do\n       puts \"This will generate #{count} record of Users, Offers, Packages, OrdersPackages, Orders, Contacts & Organisations\"\n       create_offers\n-      create_package\n-      create_orders_packages\n       create_orders\n       create_contacts\n       create_organizations\n     end\n \n     def create_offers\n-      puts \"Offers:\\t\\t\\tCreating #{count} draft offers, #{count} submitted, #{count} under_review, #{count} reviewed, #{count} scheduled (with_transport), #{count} closed(with_transport)\"\n+      puts \"Offers:\\tCreating #{count} submitted, #{count} under_review, #{count} reviewed, #{count} scheduled , #{count} closed, #{count} receiving, #{count} received Offers\"\n       count.times do\n-        FactoryGirl.create(:offer, :with_demo_items, :with_messages, created_by: donor)\n-        FactoryGirl.create(:offer, :submitted, :with_demo_items, :with_messages, created_by: donor)\n-        FactoryGirl.create(:offer, :under_review, :with_demo_items, :with_messages, created_by: donor)\n-        FactoryGirl.create(:offer, :reviewed, :with_demo_items, :with_messages, created_by: donor)\n-        FactoryGirl.create(:offer, :scheduled, :with_transport, :with_demo_items, :with_messages, created_by: donor)\n-        offer = FactoryGirl.create(:offer, :closed, :with_transport, :with_demo_items, :with_messages, created_by: donor)\n-        Package.joins(item: :offer).where(\"offers.id = ?\", offer.id).each do |package|\n-          package.allow_web_publish = true\n-        end\n+        offer = create_submitted_offer\n+        puts \"\\t\\tCreated Offer #{offer.id} in 'submitted' state\"\n+        offer = create_reviewing_offer\n+        puts \"\\t\\tCreated Offer #{offer.id} in 'under_review' state\"\n+        offer = create_reviewed_offer\n+        puts \"\\t\\tCreated Offer #{offer.id} in 'reviewed' state\"\n+        offer = create_scheduled_offer\n+        puts \"\\t\\tCreated Offer #{offer.id} in 'scheduled' state\"\n+        offer = create_closed_offer\n+        puts \"\\t\\tCreated Offer #{offer.id} in 'closed' state\"\n+        offer = create_inactive_offer\n+        puts \"\\t\\tCreated Offer #{offer.id} in 'inactive' state\"\n+        offer = create_receiving_offer\n+        puts \"\\t\\tCreated Offer #{offer.id} in 'receiving' state\"\n+        offer = create_recieved_offer\n+        puts \"\\t\\tCreated Offer #{offer.id} in 'received' state\"\n       end\n     end\n \n-    def create_package\n-      # Create Packages for Goodcity and Items for Stockit\n-      puts \"Package:\\t\\tCreating #{count} Packages for Goodcity and Items for Stockit(with_item, with_set_item, received(published and unpublished) & stockit_package\"\n-\n-      count.times do\n-        FactoryGirl.create(:package, :with_item, :package_with_locations, :with_inventory_number)\n-      end\n-      count.times do\n-        FactoryGirl.create(:package, :stockit_package, :with_inventory_number , :package_with_locations)\n-      end\n-      count.times do\n-        FactoryGirl.create(:package, :with_set_item, :package_with_locations)\n-      end\n+    def create_orders\n+      puts \"Orders:\\tCreating #{count} designated and #{count} dispatched order with orders_packages \"\n       count.times do\n-        FactoryGirl.create(:package, :received, :with_inventory_number)\n+        create_designated_packages\n+        puts \"\\t\\tCreated Order #{Order.last.id} with packages in Designated State\"\n+        create_dispatched_packages\n+        puts \"\\t\\tCreated Order #{Order.last.id} with packages in Dispatched State\"\n       end\n-      count.times do\n-        FactoryGirl.create(:package, :received, :with_inventory_number, :published)\n+    end\n+\n+    def create_submitted_offer\n+      offer = FactoryGirl.create(:offer, :with_demo_items, :with_messages, created_by: donor)\n+      offer.submit\n+      offer\n+    end\n+\n+    def create_reviewing_offer\n+      offer = create_submitted_offer\n+      User.current_user = reviewer\n+      offer.start_review\n+      offer\n+    end\n+\n+    def create_reviewed_offer\n+      offer = create_reviewing_offer\n+      offer.finish_review\n+      offer\n+    end\n+\n+    def create_scheduled_offer\n+      offer = create_reviewed_offer\n+      offer.schedule\n+      offer\n+    end\n+\n+    def create_inactive_offer\n+      offer = create_reviewing_offer\n+      offer.mark_inactive\n+      offer\n+    end\n+\n+    def create_closed_offer\n+      offer = create_reviewed_offer\n+      offer.mark_unwanted\n+      offer\n+    end\n+\n+    def create_receiving_offer\n+      offer = create_reviewed_offer","path":"lib/tasks/demo.rake","position":116,"original_position":116,"commit_id":"4ef74acc645fdb24ef4499b19159168f92fde985","original_commit_id":"4ef74acc645fdb24ef4499b19159168f92fde985","user":{"login":"steveyken","id":149198,"avatar_url":"https://avatars0.githubusercontent.com/u/149198?v=3","gravatar_id":"","url":"https://api.github.com/users/steveyken","html_url":"https://github.com/steveyken","followers_url":"https://api.github.com/users/steveyken/followers","following_url":"https://api.github.com/users/steveyken/following{/other_user}","gists_url":"https://api.github.com/users/steveyken/gists{/gist_id}","starred_url":"https://api.github.com/users/steveyken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveyken/subscriptions","organizations_url":"https://api.github.com/users/steveyken/orgs","repos_url":"https://api.github.com/users/steveyken/repos","events_url":"https://api.github.com/users/steveyken/events{/privacy}","received_events_url":"https://api.github.com/users/steveyken/received_events","type":"User","site_admin":false},"body":"for methods with this similar pattern, you could look at using the `tap` function in ruby. It calls a method on an object and returns the method itself... something like this:\r\n\r\n    def create_receiving_offer\r\n      create_reviewed_offer.tap(&:start_receiving)\r\n    end\r\n\r\nRead http://ruby-doc.org/core-2.4.1/Object.html#method-i-tap and http://seejohncode.com/2012/01/02/ruby-tap-that/ (particularly this last one)","created_at":"2017-04-19T11:52:39Z","updated_at":"2017-04-19T11:55:45Z","html_url":"https://github.com/crossroads/api.goodcity/pull/283#discussion_r112180841","pull_request_url":"https://api.github.com/repos/crossroads/api.goodcity/pulls/283","_links":{"self":{"href":"https://api.github.com/repos/crossroads/api.goodcity/pulls/comments/112180841"},"html":{"href":"https://github.com/crossroads/api.goodcity/pull/283#discussion_r112180841"},"pull_request":{"href":"https://api.github.com/repos/crossroads/api.goodcity/pulls/283"}}},"pull_request":{"url":"https://api.github.com/repos/crossroads/api.goodcity/pulls/283","id":116494895,"html_url":"https://github.com/crossroads/api.goodcity/pull/283","diff_url":"https://github.com/crossroads/api.goodcity/pull/283.diff","patch_url":"https://github.com/crossroads/api.goodcity/pull/283.patch","issue_url":"https://api.github.com/repos/crossroads/api.goodcity/issues/283","number":283,"state":"open","locked":false,"title":"Gcw 1405 correct demo data to sync with stockit and follow lifecycle","user":{"login":"trojanh","id":22974490,"avatar_url":"https://avatars3.githubusercontent.com/u/22974490?v=3","gravatar_id":"","url":"https://api.github.com/users/trojanh","html_url":"https://github.com/trojanh","followers_url":"https://api.github.com/users/trojanh/followers","following_url":"https://api.github.com/users/trojanh/following{/other_user}","gists_url":"https://api.github.com/users/trojanh/gists{/gist_id}","starred_url":"https://api.github.com/users/trojanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trojanh/subscriptions","organizations_url":"https://api.github.com/users/trojanh/orgs","repos_url":"https://api.github.com/users/trojanh/repos","events_url":"https://api.github.com/users/trojanh/events{/privacy}","received_events_url":"https://api.github.com/users/trojanh/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-04-19T08:35:03Z","updated_at":"2017-04-19T11:55:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"42da1fc26de57e1cdcf3208c3d21a79986d33ea0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/crossroads/api.goodcity/pulls/283/commits","review_comments_url":"https://api.github.com/repos/crossroads/api.goodcity/pulls/283/comments","review_comment_url":"https://api.github.com/repos/crossroads/api.goodcity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crossroads/api.goodcity/issues/283/comments","statuses_url":"https://api.github.com/repos/crossroads/api.goodcity/statuses/4ef74acc645fdb24ef4499b19159168f92fde985","head":{"label":"crossroads:GCW-1405-Correct-demo-data-to-sync-with-stockit-and-follow-lifecycle","ref":"GCW-1405-Correct-demo-data-to-sync-with-stockit-and-follow-lifecycle","sha":"4ef74acc645fdb24ef4499b19159168f92fde985","user":{"login":"crossroads","id":141971,"avatar_url":"https://avatars3.githubusercontent.com/u/141971?v=3","gravatar_id":"","url":"https://api.github.com/users/crossroads","html_url":"https://github.com/crossroads","followers_url":"https://api.github.com/users/crossroads/followers","following_url":"https://api.github.com/users/crossroads/following{/other_user}","gists_url":"https://api.github.com/users/crossroads/gists{/gist_id}","starred_url":"https://api.github.com/users/crossroads/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crossroads/subscriptions","organizations_url":"https://api.github.com/users/crossroads/orgs","repos_url":"https://api.github.com/users/crossroads/repos","events_url":"https://api.github.com/users/crossroads/events{/privacy}","received_events_url":"https://api.github.com/users/crossroads/received_events","type":"Organization","site_admin":false},"repo":{"id":21196107,"name":"api.goodcity","full_name":"crossroads/api.goodcity","owner":{"login":"crossroads","id":141971,"avatar_url":"https://avatars3.githubusercontent.com/u/141971?v=3","gravatar_id":"","url":"https://api.github.com/users/crossroads","html_url":"https://github.com/crossroads","followers_url":"https://api.github.com/users/crossroads/followers","following_url":"https://api.github.com/users/crossroads/following{/other_user}","gists_url":"https://api.github.com/users/crossroads/gists{/gist_id}","starred_url":"https://api.github.com/users/crossroads/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crossroads/subscriptions","organizations_url":"https://api.github.com/users/crossroads/orgs","repos_url":"https://api.github.com/users/crossroads/repos","events_url":"https://api.github.com/users/crossroads/events{/privacy}","received_events_url":"https://api.github.com/users/crossroads/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crossroads/api.goodcity","description":"Good City API server","fork":false,"url":"https://api.github.com/repos/crossroads/api.goodcity","forks_url":"https://api.github.com/repos/crossroads/api.goodcity/forks","keys_url":"https://api.github.com/repos/crossroads/api.goodcity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crossroads/api.goodcity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crossroads/api.goodcity/teams","hooks_url":"https://api.github.com/repos/crossroads/api.goodcity/hooks","issue_events_url":"https://api.github.com/repos/crossroads/api.goodcity/issues/events{/number}","events_url":"https://api.github.com/repos/crossroads/api.goodcity/events","assignees_url":"https://api.github.com/repos/crossroads/api.goodcity/assignees{/user}","branches_url":"https://api.github.com/repos/crossroads/api.goodcity/branches{/branch}","tags_url":"https://api.github.com/repos/crossroads/api.goodcity/tags","blobs_url":"https://api.github.com/repos/crossroads/api.goodcity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crossroads/api.goodcity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crossroads/api.goodcity/git/refs{/sha}","trees_url":"https://api.github.com/repos/crossroads/api.goodcity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crossroads/api.goodcity/statuses/{sha}","languages_url":"https://api.github.com/repos/crossroads/api.goodcity/languages","stargazers_url":"https://api.github.com/repos/crossroads/api.goodcity/stargazers","contributors_url":"https://api.github.com/repos/crossroads/api.goodcity/contributors","subscribers_url":"https://api.github.com/repos/crossroads/api.goodcity/subscribers","subscription_url":"https://api.github.com/repos/crossroads/api.goodcity/subscription","commits_url":"https://api.github.com/repos/crossroads/api.goodcity/commits{/sha}","git_commits_url":"https://api.github.com/repos/crossroads/api.goodcity/git/commits{/sha}","comments_url":"https://api.github.com/repos/crossroads/api.goodcity/comments{/number}","issue_comment_url":"https://api.github.com/repos/crossroads/api.goodcity/issues/comments{/number}","contents_url":"https://api.github.com/repos/crossroads/api.goodcity/contents/{+path}","compare_url":"https://api.github.com/repos/crossroads/api.goodcity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crossroads/api.goodcity/merges","archive_url":"https://api.github.com/repos/crossroads/api.goodcity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crossroads/api.goodcity/downloads","issues_url":"https://api.github.com/repos/crossroads/api.goodcity/issues{/number}","pulls_url":"https://api.github.com/repos/crossroads/api.goodcity/pulls{/number}","milestones_url":"https://api.github.com/repos/crossroads/api.goodcity/milestones{/number}","notifications_url":"https://api.github.com/repos/crossroads/api.goodcity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crossroads/api.goodcity/labels{/name}","releases_url":"https://api.github.com/repos/crossroads/api.goodcity/releases{/id}","deployments_url":"https://api.github.com/repos/crossroads/api.goodcity/deployments","created_at":"2014-06-25T08:40:40Z","updated_at":"2017-02-14T17:53:05Z","pushed_at":"2017-04-19T11:30:22Z","git_url":"git://github.com/crossroads/api.goodcity.git","ssh_url":"git@github.com:crossroads/api.goodcity.git","clone_url":"https://github.com/crossroads/api.goodcity.git","svn_url":"https://github.com/crossroads/api.goodcity","homepage":"http://api.goodcity.hk","size":3892,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":4,"default_branch":"master"}},"base":{"label":"crossroads:master","ref":"master","sha":"45c802e90d6fbe0a203ef6db23e14f2c2bcf8806","user":{"login":"crossroads","id":141971,"avatar_url":"https://avatars3.githubusercontent.com/u/141971?v=3","gravatar_id":"","url":"https://api.github.com/users/crossroads","html_url":"https://github.com/crossroads","followers_url":"https://api.github.com/users/crossroads/followers","following_url":"https://api.github.com/users/crossroads/following{/other_user}","gists_url":"https://api.github.com/users/crossroads/gists{/gist_id}","starred_url":"https://api.github.com/users/crossroads/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crossroads/subscriptions","organizations_url":"https://api.github.com/users/crossroads/orgs","repos_url":"https://api.github.com/users/crossroads/repos","events_url":"https://api.github.com/users/crossroads/events{/privacy}","received_events_url":"https://api.github.com/users/crossroads/received_events","type":"Organization","site_admin":false},"repo":{"id":21196107,"name":"api.goodcity","full_name":"crossroads/api.goodcity","owner":{"login":"crossroads","id":141971,"avatar_url":"https://avatars3.githubusercontent.com/u/141971?v=3","gravatar_id":"","url":"https://api.github.com/users/crossroads","html_url":"https://github.com/crossroads","followers_url":"https://api.github.com/users/crossroads/followers","following_url":"https://api.github.com/users/crossroads/following{/other_user}","gists_url":"https://api.github.com/users/crossroads/gists{/gist_id}","starred_url":"https://api.github.com/users/crossroads/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crossroads/subscriptions","organizations_url":"https://api.github.com/users/crossroads/orgs","repos_url":"https://api.github.com/users/crossroads/repos","events_url":"https://api.github.com/users/crossroads/events{/privacy}","received_events_url":"https://api.github.com/users/crossroads/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crossroads/api.goodcity","description":"Good City API server","fork":false,"url":"https://api.github.com/repos/crossroads/api.goodcity","forks_url":"https://api.github.com/repos/crossroads/api.goodcity/forks","keys_url":"https://api.github.com/repos/crossroads/api.goodcity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crossroads/api.goodcity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crossroads/api.goodcity/teams","hooks_url":"https://api.github.com/repos/crossroads/api.goodcity/hooks","issue_events_url":"https://api.github.com/repos/crossroads/api.goodcity/issues/events{/number}","events_url":"https://api.github.com/repos/crossroads/api.goodcity/events","assignees_url":"https://api.github.com/repos/crossroads/api.goodcity/assignees{/user}","branches_url":"https://api.github.com/repos/crossroads/api.goodcity/branches{/branch}","tags_url":"https://api.github.com/repos/crossroads/api.goodcity/tags","blobs_url":"https://api.github.com/repos/crossroads/api.goodcity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crossroads/api.goodcity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crossroads/api.goodcity/git/refs{/sha}","trees_url":"https://api.github.com/repos/crossroads/api.goodcity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crossroads/api.goodcity/statuses/{sha}","languages_url":"https://api.github.com/repos/crossroads/api.goodcity/languages","stargazers_url":"https://api.github.com/repos/crossroads/api.goodcity/stargazers","contributors_url":"https://api.github.com/repos/crossroads/api.goodcity/contributors","subscribers_url":"https://api.github.com/repos/crossroads/api.goodcity/subscribers","subscription_url":"https://api.github.com/repos/crossroads/api.goodcity/subscription","commits_url":"https://api.github.com/repos/crossroads/api.goodcity/commits{/sha}","git_commits_url":"https://api.github.com/repos/crossroads/api.goodcity/git/commits{/sha}","comments_url":"https://api.github.com/repos/crossroads/api.goodcity/comments{/number}","issue_comment_url":"https://api.github.com/repos/crossroads/api.goodcity/issues/comments{/number}","contents_url":"https://api.github.com/repos/crossroads/api.goodcity/contents/{+path}","compare_url":"https://api.github.com/repos/crossroads/api.goodcity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crossroads/api.goodcity/merges","archive_url":"https://api.github.com/repos/crossroads/api.goodcity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crossroads/api.goodcity/downloads","issues_url":"https://api.github.com/repos/crossroads/api.goodcity/issues{/number}","pulls_url":"https://api.github.com/repos/crossroads/api.goodcity/pulls{/number}","milestones_url":"https://api.github.com/repos/crossroads/api.goodcity/milestones{/number}","notifications_url":"https://api.github.com/repos/crossroads/api.goodcity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crossroads/api.goodcity/labels{/name}","releases_url":"https://api.github.com/repos/crossroads/api.goodcity/releases{/id}","deployments_url":"https://api.github.com/repos/crossroads/api.goodcity/deployments","created_at":"2014-06-25T08:40:40Z","updated_at":"2017-02-14T17:53:05Z","pushed_at":"2017-04-19T11:30:22Z","git_url":"git://github.com/crossroads/api.goodcity.git","ssh_url":"git@github.com:crossroads/api.goodcity.git","clone_url":"https://github.com/crossroads/api.goodcity.git","svn_url":"https://github.com/crossroads/api.goodcity","homepage":"http://api.goodcity.hk","size":3892,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crossroads/api.goodcity/pulls/283"},"html":{"href":"https://github.com/crossroads/api.goodcity/pull/283"},"issue":{"href":"https://api.github.com/repos/crossroads/api.goodcity/issues/283"},"comments":{"href":"https://api.github.com/repos/crossroads/api.goodcity/issues/283/comments"},"review_comments":{"href":"https://api.github.com/repos/crossroads/api.goodcity/pulls/283/comments"},"review_comment":{"href":"https://api.github.com/repos/crossroads/api.goodcity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crossroads/api.goodcity/pulls/283/commits"},"statuses":{"href":"https://api.github.com/repos/crossroads/api.goodcity/statuses/4ef74acc645fdb24ef4499b19159168f92fde985"}}}}
{"actor":{"display_login":"steveyken"}}