{"action":"created","comment":{"url":"https://api.github.com/repos/openSUSE/osem/pulls/comments/55544629","id":55544629,"diff_hunk":"@@ -1,24 +1,79 @@\n-#!/bin/env ruby\n-# encoding: utf-8\n require 'spec_helper'\n \n-describe 'Registration' do\n-  describe 'validations' do\n+describe Registration do\n+  subject { create(:registration) }\n+\n+  describe 'validation' do\n+\n     it 'has a valid factory' do\n       expect(build(:registration)).to be_valid\n     end\n \n+    it { should validate_presence_of(:user) }\n+\n+    it 'validates uniqueness of user in scope of conference' do\n+      expect(build(:registration, conference: subject.conference, user: subject.user)).not_to be_valid\n+    end\n+\n     describe 'registration_limit_not_exceed' do\n-      it 'is not valid when limit exceeded' do\n-        conference = build(:conference)\n-        conference.registration_limit = 1\n-        registration1 = build(:registration, conference: conference)\n-        registration1.save\n-        registration2 = build(:registration, conference: conference)\n-        registration2.save\n-        expect(conference.registrations.size).to be 1\n-        expect(registration2.valid?).to be false\n-        expect(registration2.errors.full_messages).to eq(['Registration limit exceeded'])\n+      context 'registration_limit has exceeded' do\n+        before do\n+          conference = create(:conference, registration_limit: 1)\n+          create(:registration, conference: conference)\n+          @second_registration = build(:registration, conference: conference)\n+        end\n+\n+        it 'is not valid factory' do\n+          expect(@second_registration.valid?).to be false\n+          expect(@second_registration.errors.full_messages).to eq(['Registration limit exceeded'])\n+        end\n+      end\n+    end\n+  end\n+\n+  describe 'association' do\n+    it { should belong_to(:user) }\n+    it { should belong_to(:conference) }\n+    it { should belong_to(:dietary_choice) }\n+    it { should have_and_belong_to_many(:social_events) }\n+    it { should have_and_belong_to_many(:events) }\n+    it { should have_and_belong_to_many(:qanswers) }\n+    it { should have_and_belong_to_many(:vchoices) }\n+    it { should have_many(:events_registrations) }\n+    it { should have_many(:workshops) }\n+  end\n+\n+  describe 'callback' do\n+    after { subject.run_callbacks(:create) }\n+\n+    # set_week and subscribe_to_conference are private methods\n+    describe '#set_week' do\n+      before { subject.created_at = Time.utc(2014, 5, 10) }\n+\n+      it 'sets week of registration' do\n+        expect(subject).to receive(:set_week)\n+        expect(subject.week).to eq 18\n+      end\n+    end\n+\n+    describe '#subscribe_to_conference' do\n+      it 'subscribes to conference' do\n+        expect(subject).to receive(:subscribe_to_conference)\n+        expect(subject.user.subscribed?(subject.conference)).to be_truthy","path":"spec/models/registration_spec.rb","position":76,"original_position":76,"commit_id":"bb180e1b4162a59399dddd652fef5626326737ec","original_commit_id":"bb180e1b4162a59399dddd652fef5626326737ec","user":{"login":"differentreality","id":4322737,"avatar_url":"https://avatars.githubusercontent.com/u/4322737?v=3","gravatar_id":"","url":"https://api.github.com/users/differentreality","html_url":"https://github.com/differentreality","followers_url":"https://api.github.com/users/differentreality/followers","following_url":"https://api.github.com/users/differentreality/following{/other_user}","gists_url":"https://api.github.com/users/differentreality/gists{/gist_id}","starred_url":"https://api.github.com/users/differentreality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/differentreality/subscriptions","organizations_url":"https://api.github.com/users/differentreality/orgs","repos_url":"https://api.github.com/users/differentreality/repos","events_url":"https://api.github.com/users/differentreality/events{/privacy}","received_events_url":"https://api.github.com/users/differentreality/received_events","type":"User","site_admin":false},"body":"user.subscribed? returns either true or false. We want this to be true. Explicitely, not truthy.","created_at":"2016-03-09T16:25:14Z","updated_at":"2016-03-09T16:25:14Z","html_url":"https://github.com/openSUSE/osem/pull/795#discussion_r55544629","pull_request_url":"https://api.github.com/repos/openSUSE/osem/pulls/795","_links":{"self":{"href":"https://api.github.com/repos/openSUSE/osem/pulls/comments/55544629"},"html":{"href":"https://github.com/openSUSE/osem/pull/795#discussion_r55544629"},"pull_request":{"href":"https://api.github.com/repos/openSUSE/osem/pulls/795"}}},"pull_request":{"url":"https://api.github.com/repos/openSUSE/osem/pulls/795","id":60897349,"html_url":"https://github.com/openSUSE/osem/pull/795","diff_url":"https://github.com/openSUSE/osem/pull/795.diff","patch_url":"https://github.com/openSUSE/osem/pull/795.patch","issue_url":"https://api.github.com/repos/openSUSE/osem/issues/795","number":795,"state":"open","locked":false,"title":"Fix authorization of registration controller and add tests","user":{"login":"sonalkr132","id":7680662,"avatar_url":"https://avatars.githubusercontent.com/u/7680662?v=3","gravatar_id":"","url":"https://api.github.com/users/sonalkr132","html_url":"https://github.com/sonalkr132","followers_url":"https://api.github.com/users/sonalkr132/followers","following_url":"https://api.github.com/users/sonalkr132/following{/other_user}","gists_url":"https://api.github.com/users/sonalkr132/gists{/gist_id}","starred_url":"https://api.github.com/users/sonalkr132/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonalkr132/subscriptions","organizations_url":"https://api.github.com/users/sonalkr132/orgs","repos_url":"https://api.github.com/users/sonalkr132/repos","events_url":"https://api.github.com/users/sonalkr132/events{/privacy}","received_events_url":"https://api.github.com/users/sonalkr132/received_events","type":"User","site_admin":false},"body":"Test of new action serves as test of before_filter :registration_period_inclusion.\r\nChange in proposal spec cause conference has to have valid registration\r\nperiod for successful redirect to registration after confirm proposal.\r\n\r\nCloses: #791\r\n\r\nI feel like there is no need of adding validation to model as requests with invalid registration objects (wrt to registration period) won't ever reach registration model. Should I add it anyway?","created_at":"2016-02-26T20:14:33Z","updated_at":"2016-03-09T16:25:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ae7bd2470f3f63a6c4acd0f151f9dd3dbd5744e","assignee":{"login":"differentreality","id":4322737,"avatar_url":"https://avatars.githubusercontent.com/u/4322737?v=3","gravatar_id":"","url":"https://api.github.com/users/differentreality","html_url":"https://github.com/differentreality","followers_url":"https://api.github.com/users/differentreality/followers","following_url":"https://api.github.com/users/differentreality/following{/other_user}","gists_url":"https://api.github.com/users/differentreality/gists{/gist_id}","starred_url":"https://api.github.com/users/differentreality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/differentreality/subscriptions","organizations_url":"https://api.github.com/users/differentreality/orgs","repos_url":"https://api.github.com/users/differentreality/repos","events_url":"https://api.github.com/users/differentreality/events{/privacy}","received_events_url":"https://api.github.com/users/differentreality/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/openSUSE/osem/pulls/795/commits","review_comments_url":"https://api.github.com/repos/openSUSE/osem/pulls/795/comments","review_comment_url":"https://api.github.com/repos/openSUSE/osem/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openSUSE/osem/issues/795/comments","statuses_url":"https://api.github.com/repos/openSUSE/osem/statuses/bb180e1b4162a59399dddd652fef5626326737ec","head":{"label":"sonalkr132:registration_period","ref":"registration_period","sha":"bb180e1b4162a59399dddd652fef5626326737ec","user":{"login":"sonalkr132","id":7680662,"avatar_url":"https://avatars.githubusercontent.com/u/7680662?v=3","gravatar_id":"","url":"https://api.github.com/users/sonalkr132","html_url":"https://github.com/sonalkr132","followers_url":"https://api.github.com/users/sonalkr132/followers","following_url":"https://api.github.com/users/sonalkr132/following{/other_user}","gists_url":"https://api.github.com/users/sonalkr132/gists{/gist_id}","starred_url":"https://api.github.com/users/sonalkr132/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonalkr132/subscriptions","organizations_url":"https://api.github.com/users/sonalkr132/orgs","repos_url":"https://api.github.com/users/sonalkr132/repos","events_url":"https://api.github.com/users/sonalkr132/events{/privacy}","received_events_url":"https://api.github.com/users/sonalkr132/received_events","type":"User","site_admin":false},"repo":{"id":31470075,"name":"osem","full_name":"sonalkr132/osem","owner":{"login":"sonalkr132","id":7680662,"avatar_url":"https://avatars.githubusercontent.com/u/7680662?v=3","gravatar_id":"","url":"https://api.github.com/users/sonalkr132","html_url":"https://github.com/sonalkr132","followers_url":"https://api.github.com/users/sonalkr132/followers","following_url":"https://api.github.com/users/sonalkr132/following{/other_user}","gists_url":"https://api.github.com/users/sonalkr132/gists{/gist_id}","starred_url":"https://api.github.com/users/sonalkr132/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonalkr132/subscriptions","organizations_url":"https://api.github.com/users/sonalkr132/orgs","repos_url":"https://api.github.com/users/sonalkr132/repos","events_url":"https://api.github.com/users/sonalkr132/events{/privacy}","received_events_url":"https://api.github.com/users/sonalkr132/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sonalkr132/osem","description":"Open Source Event Manager. An event management tool tailored to Free and Open Source Software conferences.","fork":true,"url":"https://api.github.com/repos/sonalkr132/osem","forks_url":"https://api.github.com/repos/sonalkr132/osem/forks","keys_url":"https://api.github.com/repos/sonalkr132/osem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sonalkr132/osem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sonalkr132/osem/teams","hooks_url":"https://api.github.com/repos/sonalkr132/osem/hooks","issue_events_url":"https://api.github.com/repos/sonalkr132/osem/issues/events{/number}","events_url":"https://api.github.com/repos/sonalkr132/osem/events","assignees_url":"https://api.github.com/repos/sonalkr132/osem/assignees{/user}","branches_url":"https://api.github.com/repos/sonalkr132/osem/branches{/branch}","tags_url":"https://api.github.com/repos/sonalkr132/osem/tags","blobs_url":"https://api.github.com/repos/sonalkr132/osem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sonalkr132/osem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sonalkr132/osem/git/refs{/sha}","trees_url":"https://api.github.com/repos/sonalkr132/osem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sonalkr132/osem/statuses/{sha}","languages_url":"https://api.github.com/repos/sonalkr132/osem/languages","stargazers_url":"https://api.github.com/repos/sonalkr132/osem/stargazers","contributors_url":"https://api.github.com/repos/sonalkr132/osem/contributors","subscribers_url":"https://api.github.com/repos/sonalkr132/osem/subscribers","subscription_url":"https://api.github.com/repos/sonalkr132/osem/subscription","commits_url":"https://api.github.com/repos/sonalkr132/osem/commits{/sha}","git_commits_url":"https://api.github.com/repos/sonalkr132/osem/git/commits{/sha}","comments_url":"https://api.github.com/repos/sonalkr132/osem/comments{/number}","issue_comment_url":"https://api.github.com/repos/sonalkr132/osem/issues/comments{/number}","contents_url":"https://api.github.com/repos/sonalkr132/osem/contents/{+path}","compare_url":"https://api.github.com/repos/sonalkr132/osem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sonalkr132/osem/merges","archive_url":"https://api.github.com/repos/sonalkr132/osem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sonalkr132/osem/downloads","issues_url":"https://api.github.com/repos/sonalkr132/osem/issues{/number}","pulls_url":"https://api.github.com/repos/sonalkr132/osem/pulls{/number}","milestones_url":"https://api.github.com/repos/sonalkr132/osem/milestones{/number}","notifications_url":"https://api.github.com/repos/sonalkr132/osem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sonalkr132/osem/labels{/name}","releases_url":"https://api.github.com/repos/sonalkr132/osem/releases{/id}","deployments_url":"https://api.github.com/repos/sonalkr132/osem/deployments","created_at":"2015-02-28T17:30:19Z","updated_at":"2016-02-18T05:57:21Z","pushed_at":"2016-03-09T16:23:49Z","git_url":"git://github.com/sonalkr132/osem.git","ssh_url":"git@github.com:sonalkr132/osem.git","clone_url":"https://github.com/sonalkr132/osem.git","svn_url":"https://github.com/sonalkr132/osem","homepage":"http://osem.io","size":20850,"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":"openSUSE:master","ref":"master","sha":"976616b47bd9669cb16dc7f97d228ac6cabab2a5","user":{"login":"openSUSE","id":623819,"avatar_url":"https://avatars.githubusercontent.com/u/623819?v=3","gravatar_id":"","url":"https://api.github.com/users/openSUSE","html_url":"https://github.com/openSUSE","followers_url":"https://api.github.com/users/openSUSE/followers","following_url":"https://api.github.com/users/openSUSE/following{/other_user}","gists_url":"https://api.github.com/users/openSUSE/gists{/gist_id}","starred_url":"https://api.github.com/users/openSUSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openSUSE/subscriptions","organizations_url":"https://api.github.com/users/openSUSE/orgs","repos_url":"https://api.github.com/users/openSUSE/repos","events_url":"https://api.github.com/users/openSUSE/events{/privacy}","received_events_url":"https://api.github.com/users/openSUSE/received_events","type":"Organization","site_admin":false},"repo":{"id":5911225,"name":"osem","full_name":"openSUSE/osem","owner":{"login":"openSUSE","id":623819,"avatar_url":"https://avatars.githubusercontent.com/u/623819?v=3","gravatar_id":"","url":"https://api.github.com/users/openSUSE","html_url":"https://github.com/openSUSE","followers_url":"https://api.github.com/users/openSUSE/followers","following_url":"https://api.github.com/users/openSUSE/following{/other_user}","gists_url":"https://api.github.com/users/openSUSE/gists{/gist_id}","starred_url":"https://api.github.com/users/openSUSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openSUSE/subscriptions","organizations_url":"https://api.github.com/users/openSUSE/orgs","repos_url":"https://api.github.com/users/openSUSE/repos","events_url":"https://api.github.com/users/openSUSE/events{/privacy}","received_events_url":"https://api.github.com/users/openSUSE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openSUSE/osem","description":"Open Source Event Manager. An event management tool tailored to Free and Open Source Software conferences.","fork":false,"url":"https://api.github.com/repos/openSUSE/osem","forks_url":"https://api.github.com/repos/openSUSE/osem/forks","keys_url":"https://api.github.com/repos/openSUSE/osem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openSUSE/osem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openSUSE/osem/teams","hooks_url":"https://api.github.com/repos/openSUSE/osem/hooks","issue_events_url":"https://api.github.com/repos/openSUSE/osem/issues/events{/number}","events_url":"https://api.github.com/repos/openSUSE/osem/events","assignees_url":"https://api.github.com/repos/openSUSE/osem/assignees{/user}","branches_url":"https://api.github.com/repos/openSUSE/osem/branches{/branch}","tags_url":"https://api.github.com/repos/openSUSE/osem/tags","blobs_url":"https://api.github.com/repos/openSUSE/osem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openSUSE/osem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openSUSE/osem/git/refs{/sha}","trees_url":"https://api.github.com/repos/openSUSE/osem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openSUSE/osem/statuses/{sha}","languages_url":"https://api.github.com/repos/openSUSE/osem/languages","stargazers_url":"https://api.github.com/repos/openSUSE/osem/stargazers","contributors_url":"https://api.github.com/repos/openSUSE/osem/contributors","subscribers_url":"https://api.github.com/repos/openSUSE/osem/subscribers","subscription_url":"https://api.github.com/repos/openSUSE/osem/subscription","commits_url":"https://api.github.com/repos/openSUSE/osem/commits{/sha}","git_commits_url":"https://api.github.com/repos/openSUSE/osem/git/commits{/sha}","comments_url":"https://api.github.com/repos/openSUSE/osem/comments{/number}","issue_comment_url":"https://api.github.com/repos/openSUSE/osem/issues/comments{/number}","contents_url":"https://api.github.com/repos/openSUSE/osem/contents/{+path}","compare_url":"https://api.github.com/repos/openSUSE/osem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openSUSE/osem/merges","archive_url":"https://api.github.com/repos/openSUSE/osem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openSUSE/osem/downloads","issues_url":"https://api.github.com/repos/openSUSE/osem/issues{/number}","pulls_url":"https://api.github.com/repos/openSUSE/osem/pulls{/number}","milestones_url":"https://api.github.com/repos/openSUSE/osem/milestones{/number}","notifications_url":"https://api.github.com/repos/openSUSE/osem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openSUSE/osem/labels{/name}","releases_url":"https://api.github.com/repos/openSUSE/osem/releases{/id}","deployments_url":"https://api.github.com/repos/openSUSE/osem/deployments","created_at":"2012-09-22T07:40:18Z","updated_at":"2016-03-07T23:09:13Z","pushed_at":"2016-03-09T16:08:07Z","git_url":"git://github.com/openSUSE/osem.git","ssh_url":"git@github.com:openSUSE/osem.git","clone_url":"https://github.com/openSUSE/osem.git","svn_url":"https://github.com/openSUSE/osem","homepage":"http://osem.io","size":21596,"stargazers_count":108,"watchers_count":108,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":80,"mirror_url":null,"open_issues_count":96,"forks":80,"open_issues":96,"watchers":108,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openSUSE/osem/pulls/795"},"html":{"href":"https://github.com/openSUSE/osem/pull/795"},"issue":{"href":"https://api.github.com/repos/openSUSE/osem/issues/795"},"comments":{"href":"https://api.github.com/repos/openSUSE/osem/issues/795/comments"},"review_comments":{"href":"https://api.github.com/repos/openSUSE/osem/pulls/795/comments"},"review_comment":{"href":"https://api.github.com/repos/openSUSE/osem/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openSUSE/osem/pulls/795/commits"},"statuses":{"href":"https://api.github.com/repos/openSUSE/osem/statuses/bb180e1b4162a59399dddd652fef5626326737ec"}}}}