{"action":"created","comment":{"url":"https://api.github.com/repos/YaleSTC/shifts/pulls/comments/31475334","id":31475334,"diff_hunk":"@@ -1,71 +1,94 @@\n-require 'spec_helper'\n-require 'capybara/rails'\n+require 'rails_helper'\n \n-\n-describe \"timeslot creation process\", :type => :feature do\n+describe \"TimeSlot\" , :time_slot do\n   before :each do\n-    Timecop.freeze(Time.local(2014, 9, 1, 10, 5, 0))\n-    app_setup\n-    @user = create(:admin)\n-    sign_in(@user.login)\n-  end\n-\n-  it \"can view the main page\" do\n-    visit '/'\n-    # save_and_open_page\n-    expect(page).to have_content 'Your Shifts'\n+    full_setup\n+    sign_in(@admin.login)\n   end\n \n-  it \"creates a timeslot\" do\n-    create_timeslot\n-    expect(page).to have_content 'Success'\n-  end\n+  context \"For one-time timeslot\" do \n+    it \"can create time_slot\" do\n+      expect do\n+        create_timeslot(Date.today)\n+        expect_flash_notice \"Successfully created timeslot(s)\"\n+      end.to change{TimeSlot.count}.by(1)\n+    end\n \n-  it \"displays the timeslot at all\" do\n-    create_timeslot\n-    visit '/time_slots'\n-    expect(page).to have_css('.time-slot')\n-  end\n+    context \"when timeslot is created\", :shift do\n+      before :each do\n+        @slot = create(:time_slot, location: @location, calendar: @calendar)\n+      end\n \n-  xit \"displays the timeslot properly on the time slots page\" do\n-    create_timeslot\n-    visit '/time_slots'    \n-    # expect(SPECIFIC ROW).to have_css('.time-slot')\n-  end\n+      it \"displays the timeslot properly on the time slots page\" do\n+        visit '/time_slots'\n+        expect_time_slot_to_display_properly(@slot, time_slot_row(@slot.location.id, Date.today).find('li.timeslot'))\n+      end\n \n-  xit \"displays the timeslot properly on the shifts page\" do\n-    visit '/shifts'\n-  end\n-end\n+      # Note that the part of time_slot in the past is not open\n+      it \"displays the timeslot properly on the shifts schedule page\" do \n+        visit shifts_path\n+        expect_time_slot_to_display_properly(@slot, shift_schedule_row(@slot.location.id, Date.today).find('li.bar_open'))\n+      end\n \n+      # Note that when new loc_groups are created, the roles are NOT updated \n+      # with the newly-generated permissions, therefore this new timeslot would\n+      # not be displayed on the timeslots page\n+      it \"can update timeslot\" do \n+        c = create(:calendar); loc = create(:location)\n+        visit edit_time_slot_path(@slot)\n+        select c.name, from: \"Calendar\"\n+        fill_in_date(\"time_slot_start_date\", @slot.start+2.day)\n+        select loc.name, from: \"Location\"\n+        click_on \"Save Changes\"\n+        expect_flash_notice \"Successfully updated timeslot\"\n+        expect{@slot.reload}.to change(@slot, :start)\n+        expect(@slot.calendar).to eq(c)\n+        expect(@slot.location).to eq(loc)\n+      end\n \n-#\n-## Common Actions\n-#\n+      # Alternatively, one can use selenium to handle alert\n+      it \"can destroy timeslot\" do \n+        visit time_slot_path(@slot)\n+        click_on \"Destroy\"\n+        # If using selenium driver\n+        # page.driver.browser.switch_to.alert.accept\n+        expect_flash_notice \"Successfully destroyed timeslot\"\n+        expect{TimeSlot.find(@slot.id)}.to raise_error(ActiveRecord::RecordNotFound)\n+      end\n \n-def app_setup\n-  @app_config = create(:app_config)\n-  @department = create(:department)\n-  @loc_group = build(:loc_group, department: @department)\n-  @location = create(:location, loc_group: @loc_group)\n-end\n+    end\n+  end\n \n-def create_timeslot\n-  visit '/time_slots/new'\n-  within(\"#new_time_slot\") do\n-    # fill_in DATE, :with => TOMORROW\n-    # fill_in time_slot_start_time_4i, :with => \"10\" #10am\n-    # ...more time\n+  context \"For repeating time_slots\" do \n+    # Need JavaScript for the deletion submenu to work\n+    context \"Different types of deletion\", js: true do\n+      before :each do \n+        @re = create(:repeating_time_slots, location_ids: [@location.id], calendar: @calendar)\n+        # getting the second timeslot in the series\n+        @slot = @re.time_slots.order(:start).second\n+        @count = TimeSlot.count\n+        visit edit_time_slot_path(@slot)\n+        click_on \"Destroy this time slot\"\n+      end\n+      it \"can delete one single instance of timeslot\" do \n+        click_on \"Just this time slot\"\n+        expect_flash_notice \"Successfully destroyed timeslot\"\n+        expect{TimeSlot.find(@slot.id)}.to raise_error(ActiveRecord::RecordNotFound)","path":"spec/features/time_slots_spec.rb","position":123,"original_position":123,"commit_id":"cf55a7d858fb0e07fd3e9fc72ad2367668f12bef","original_commit_id":"cf55a7d858fb0e07fd3e9fc72ad2367668f12bef","user":{"login":"shippy","id":1340280,"avatar_url":"https://avatars.githubusercontent.com/u/1340280?v=3","gravatar_id":"","url":"https://api.github.com/users/shippy","html_url":"https://github.com/shippy","followers_url":"https://api.github.com/users/shippy/followers","following_url":"https://api.github.com/users/shippy/following{/other_user}","gists_url":"https://api.github.com/users/shippy/gists{/gist_id}","starred_url":"https://api.github.com/users/shippy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shippy/subscriptions","organizations_url":"https://api.github.com/users/shippy/orgs","repos_url":"https://api.github.com/users/shippy/repos","events_url":"https://api.github.com/users/shippy/events{/privacy}","received_events_url":"https://api.github.com/users/shippy/received_events","type":"User","site_admin":false},"body":"Is there a reason why this doesn't measure count change? (AR::RNF could, in theory, be raised if the setup fails and @slot is not created, no?)","created_at":"2015-06-01T22:01:30Z","updated_at":"2015-06-01T22:01:30Z","html_url":"https://github.com/YaleSTC/shifts/pull/431#discussion_r31475334","pull_request_url":"https://api.github.com/repos/YaleSTC/shifts/pulls/431","_links":{"self":{"href":"https://api.github.com/repos/YaleSTC/shifts/pulls/comments/31475334"},"html":{"href":"https://github.com/YaleSTC/shifts/pull/431#discussion_r31475334"},"pull_request":{"href":"https://api.github.com/repos/YaleSTC/shifts/pulls/431"}}},"pull_request":{"url":"https://api.github.com/repos/YaleSTC/shifts/pulls/431","id":26747305,"html_url":"https://github.com/YaleSTC/shifts/pull/431","diff_url":"https://github.com/YaleSTC/shifts/pull/431.diff","patch_url":"https://github.com/YaleSTC/shifts/pull/431.patch","issue_url":"https://api.github.com/repos/YaleSTC/shifts/issues/431","number":431,"state":"closed","locked":false,"title":"367 integration tests on beta8","user":{"login":"njlxyaoxinwei","id":3580898,"avatar_url":"https://avatars.githubusercontent.com/u/3580898?v=3","gravatar_id":"","url":"https://api.github.com/users/njlxyaoxinwei","html_url":"https://github.com/njlxyaoxinwei","followers_url":"https://api.github.com/users/njlxyaoxinwei/followers","following_url":"https://api.github.com/users/njlxyaoxinwei/following{/other_user}","gists_url":"https://api.github.com/users/njlxyaoxinwei/gists{/gist_id}","starred_url":"https://api.github.com/users/njlxyaoxinwei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njlxyaoxinwei/subscriptions","organizations_url":"https://api.github.com/users/njlxyaoxinwei/orgs","repos_url":"https://api.github.com/users/njlxyaoxinwei/repos","events_url":"https://api.github.com/users/njlxyaoxinwei/events{/privacy}","received_events_url":"https://api.github.com/users/njlxyaoxinwei/received_events","type":"User","site_admin":false},"body":"Integration testing set up for beta 8. Fixes #367 \r\n- refactored structure of spec directory, making it amenable to adding more tests\r\n- Added and passed __57__ (and counting!) integration tests on First Run, User Accounts, User Profiles, Access Permissions, Locations, Location Groups, TimeSlots and Tooltips.\r\n- Added tests to check the validity of factories\r\n- Improved some form views so that labels matches input tag to facilitate testing with capybara.\r\n- Other bugfixes in the model callbacks to make the tests pass","created_at":"2015-01-01T22:55:30Z","updated_at":"2015-06-01T22:01:30Z","closed_at":"2015-02-04T21:07:33Z","merged_at":"2015-02-04T21:07:33Z","merge_commit_sha":"b90e3191902b90e3a67a47ab059747545bf982d9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/YaleSTC/shifts/pulls/431/commits","review_comments_url":"https://api.github.com/repos/YaleSTC/shifts/pulls/431/comments","review_comment_url":"https://api.github.com/repos/YaleSTC/shifts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/YaleSTC/shifts/issues/431/comments","statuses_url":"https://api.github.com/repos/YaleSTC/shifts/statuses/cf55a7d858fb0e07fd3e9fc72ad2367668f12bef","head":{"label":"YaleSTC:367_integration_tests_on_beta8","ref":"367_integration_tests_on_beta8","sha":"cf55a7d858fb0e07fd3e9fc72ad2367668f12bef","user":{"login":"YaleSTC","id":106094,"avatar_url":"https://avatars.githubusercontent.com/u/106094?v=3","gravatar_id":"","url":"https://api.github.com/users/YaleSTC","html_url":"https://github.com/YaleSTC","followers_url":"https://api.github.com/users/YaleSTC/followers","following_url":"https://api.github.com/users/YaleSTC/following{/other_user}","gists_url":"https://api.github.com/users/YaleSTC/gists{/gist_id}","starred_url":"https://api.github.com/users/YaleSTC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YaleSTC/subscriptions","organizations_url":"https://api.github.com/users/YaleSTC/orgs","repos_url":"https://api.github.com/users/YaleSTC/repos","events_url":"https://api.github.com/users/YaleSTC/events{/privacy}","received_events_url":"https://api.github.com/users/YaleSTC/received_events","type":"Organization","site_admin":false},"repo":{"id":282443,"name":"shifts","full_name":"YaleSTC/shifts","owner":{"login":"YaleSTC","id":106094,"avatar_url":"https://avatars.githubusercontent.com/u/106094?v=3","gravatar_id":"","url":"https://api.github.com/users/YaleSTC","html_url":"https://github.com/YaleSTC","followers_url":"https://api.github.com/users/YaleSTC/followers","following_url":"https://api.github.com/users/YaleSTC/following{/other_user}","gists_url":"https://api.github.com/users/YaleSTC/gists{/gist_id}","starred_url":"https://api.github.com/users/YaleSTC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YaleSTC/subscriptions","organizations_url":"https://api.github.com/users/YaleSTC/orgs","repos_url":"https://api.github.com/users/YaleSTC/repos","events_url":"https://api.github.com/users/YaleSTC/events{/privacy}","received_events_url":"https://api.github.com/users/YaleSTC/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/YaleSTC/shifts","description":"Application to easily track shifts, reports, and payforms for employees.","fork":false,"url":"https://api.github.com/repos/YaleSTC/shifts","forks_url":"https://api.github.com/repos/YaleSTC/shifts/forks","keys_url":"https://api.github.com/repos/YaleSTC/shifts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/YaleSTC/shifts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/YaleSTC/shifts/teams","hooks_url":"https://api.github.com/repos/YaleSTC/shifts/hooks","issue_events_url":"https://api.github.com/repos/YaleSTC/shifts/issues/events{/number}","events_url":"https://api.github.com/repos/YaleSTC/shifts/events","assignees_url":"https://api.github.com/repos/YaleSTC/shifts/assignees{/user}","branches_url":"https://api.github.com/repos/YaleSTC/shifts/branches{/branch}","tags_url":"https://api.github.com/repos/YaleSTC/shifts/tags","blobs_url":"https://api.github.com/repos/YaleSTC/shifts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/YaleSTC/shifts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/YaleSTC/shifts/git/refs{/sha}","trees_url":"https://api.github.com/repos/YaleSTC/shifts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/YaleSTC/shifts/statuses/{sha}","languages_url":"https://api.github.com/repos/YaleSTC/shifts/languages","stargazers_url":"https://api.github.com/repos/YaleSTC/shifts/stargazers","contributors_url":"https://api.github.com/repos/YaleSTC/shifts/contributors","subscribers_url":"https://api.github.com/repos/YaleSTC/shifts/subscribers","subscription_url":"https://api.github.com/repos/YaleSTC/shifts/subscription","commits_url":"https://api.github.com/repos/YaleSTC/shifts/commits{/sha}","git_commits_url":"https://api.github.com/repos/YaleSTC/shifts/git/commits{/sha}","comments_url":"https://api.github.com/repos/YaleSTC/shifts/comments{/number}","issue_comment_url":"https://api.github.com/repos/YaleSTC/shifts/issues/comments{/number}","contents_url":"https://api.github.com/repos/YaleSTC/shifts/contents/{+path}","compare_url":"https://api.github.com/repos/YaleSTC/shifts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/YaleSTC/shifts/merges","archive_url":"https://api.github.com/repos/YaleSTC/shifts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/YaleSTC/shifts/downloads","issues_url":"https://api.github.com/repos/YaleSTC/shifts/issues{/number}","pulls_url":"https://api.github.com/repos/YaleSTC/shifts/pulls{/number}","milestones_url":"https://api.github.com/repos/YaleSTC/shifts/milestones{/number}","notifications_url":"https://api.github.com/repos/YaleSTC/shifts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/YaleSTC/shifts/labels{/name}","releases_url":"https://api.github.com/repos/YaleSTC/shifts/releases{/id}","created_at":"2009-08-19T21:17:29Z","updated_at":"2015-04-07T04:53:17Z","pushed_at":"2015-05-22T02:47:47Z","git_url":"git://github.com/YaleSTC/shifts.git","ssh_url":"git@github.com:YaleSTC/shifts.git","clone_url":"https://github.com/YaleSTC/shifts.git","svn_url":"https://github.com/YaleSTC/shifts","homepage":"","size":34611,"stargazers_count":14,"watchers_count":14,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8,"mirror_url":null,"open_issues_count":169,"forks":8,"open_issues":169,"watchers":14,"default_branch":"master"}},"base":{"label":"YaleSTC:master","ref":"master","sha":"6a050bdeb639664a0f71123f607c795d9752cc07","user":{"login":"YaleSTC","id":106094,"avatar_url":"https://avatars.githubusercontent.com/u/106094?v=3","gravatar_id":"","url":"https://api.github.com/users/YaleSTC","html_url":"https://github.com/YaleSTC","followers_url":"https://api.github.com/users/YaleSTC/followers","following_url":"https://api.github.com/users/YaleSTC/following{/other_user}","gists_url":"https://api.github.com/users/YaleSTC/gists{/gist_id}","starred_url":"https://api.github.com/users/YaleSTC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YaleSTC/subscriptions","organizations_url":"https://api.github.com/users/YaleSTC/orgs","repos_url":"https://api.github.com/users/YaleSTC/repos","events_url":"https://api.github.com/users/YaleSTC/events{/privacy}","received_events_url":"https://api.github.com/users/YaleSTC/received_events","type":"Organization","site_admin":false},"repo":{"id":282443,"name":"shifts","full_name":"YaleSTC/shifts","owner":{"login":"YaleSTC","id":106094,"avatar_url":"https://avatars.githubusercontent.com/u/106094?v=3","gravatar_id":"","url":"https://api.github.com/users/YaleSTC","html_url":"https://github.com/YaleSTC","followers_url":"https://api.github.com/users/YaleSTC/followers","following_url":"https://api.github.com/users/YaleSTC/following{/other_user}","gists_url":"https://api.github.com/users/YaleSTC/gists{/gist_id}","starred_url":"https://api.github.com/users/YaleSTC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YaleSTC/subscriptions","organizations_url":"https://api.github.com/users/YaleSTC/orgs","repos_url":"https://api.github.com/users/YaleSTC/repos","events_url":"https://api.github.com/users/YaleSTC/events{/privacy}","received_events_url":"https://api.github.com/users/YaleSTC/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/YaleSTC/shifts","description":"Application to easily track shifts, reports, and payforms for employees.","fork":false,"url":"https://api.github.com/repos/YaleSTC/shifts","forks_url":"https://api.github.com/repos/YaleSTC/shifts/forks","keys_url":"https://api.github.com/repos/YaleSTC/shifts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/YaleSTC/shifts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/YaleSTC/shifts/teams","hooks_url":"https://api.github.com/repos/YaleSTC/shifts/hooks","issue_events_url":"https://api.github.com/repos/YaleSTC/shifts/issues/events{/number}","events_url":"https://api.github.com/repos/YaleSTC/shifts/events","assignees_url":"https://api.github.com/repos/YaleSTC/shifts/assignees{/user}","branches_url":"https://api.github.com/repos/YaleSTC/shifts/branches{/branch}","tags_url":"https://api.github.com/repos/YaleSTC/shifts/tags","blobs_url":"https://api.github.com/repos/YaleSTC/shifts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/YaleSTC/shifts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/YaleSTC/shifts/git/refs{/sha}","trees_url":"https://api.github.com/repos/YaleSTC/shifts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/YaleSTC/shifts/statuses/{sha}","languages_url":"https://api.github.com/repos/YaleSTC/shifts/languages","stargazers_url":"https://api.github.com/repos/YaleSTC/shifts/stargazers","contributors_url":"https://api.github.com/repos/YaleSTC/shifts/contributors","subscribers_url":"https://api.github.com/repos/YaleSTC/shifts/subscribers","subscription_url":"https://api.github.com/repos/YaleSTC/shifts/subscription","commits_url":"https://api.github.com/repos/YaleSTC/shifts/commits{/sha}","git_commits_url":"https://api.github.com/repos/YaleSTC/shifts/git/commits{/sha}","comments_url":"https://api.github.com/repos/YaleSTC/shifts/comments{/number}","issue_comment_url":"https://api.github.com/repos/YaleSTC/shifts/issues/comments{/number}","contents_url":"https://api.github.com/repos/YaleSTC/shifts/contents/{+path}","compare_url":"https://api.github.com/repos/YaleSTC/shifts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/YaleSTC/shifts/merges","archive_url":"https://api.github.com/repos/YaleSTC/shifts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/YaleSTC/shifts/downloads","issues_url":"https://api.github.com/repos/YaleSTC/shifts/issues{/number}","pulls_url":"https://api.github.com/repos/YaleSTC/shifts/pulls{/number}","milestones_url":"https://api.github.com/repos/YaleSTC/shifts/milestones{/number}","notifications_url":"https://api.github.com/repos/YaleSTC/shifts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/YaleSTC/shifts/labels{/name}","releases_url":"https://api.github.com/repos/YaleSTC/shifts/releases{/id}","created_at":"2009-08-19T21:17:29Z","updated_at":"2015-04-07T04:53:17Z","pushed_at":"2015-05-22T02:47:47Z","git_url":"git://github.com/YaleSTC/shifts.git","ssh_url":"git@github.com:YaleSTC/shifts.git","clone_url":"https://github.com/YaleSTC/shifts.git","svn_url":"https://github.com/YaleSTC/shifts","homepage":"","size":34611,"stargazers_count":14,"watchers_count":14,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8,"mirror_url":null,"open_issues_count":169,"forks":8,"open_issues":169,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/YaleSTC/shifts/pulls/431"},"html":{"href":"https://github.com/YaleSTC/shifts/pull/431"},"issue":{"href":"https://api.github.com/repos/YaleSTC/shifts/issues/431"},"comments":{"href":"https://api.github.com/repos/YaleSTC/shifts/issues/431/comments"},"review_comments":{"href":"https://api.github.com/repos/YaleSTC/shifts/pulls/431/comments"},"review_comment":{"href":"https://api.github.com/repos/YaleSTC/shifts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/YaleSTC/shifts/pulls/431/commits"},"statuses":{"href":"https://api.github.com/repos/YaleSTC/shifts/statuses/cf55a7d858fb0e07fd3e9fc72ad2367668f12bef"}}}}