Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-02-26 18:44:35 +0300
committerAndreas Brandl <abrandl@gitlab.com>2018-03-06 14:53:13 +0300
commit375a5c9f1e69a5fbf49a98cecc7f0c0cb61df989 (patch)
treef748f286a26b82535ad9b261806ee84bee6d66e1 /spec/models/event_spec.rb
parent8dde03012f0f3c66333916740483643b193664ad (diff)
Only track contributions if table is available.
This is due to the problem that the callback can be called while running an earlier database schema version (for example during earlier migrations). We work around this by checking the current schema version and only track contributions if the table is available.
Diffstat (limited to 'spec/models/event_spec.rb')
-rw-r--r--spec/models/event_spec.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 11f6ae74712..445de37d2b1 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -51,11 +51,19 @@ describe Event do
end
describe 'after_create :track_user_contributed_projects' do
+ let(:event) { build(:push_event, project: project, author: project.owner) }
+
it 'passes event to UserContributedProjects.track' do
- event = build(:push_event, project: project, author: project.owner)
+ expect(UserContributedProjects).to receive(:available?).and_return(true)
expect(UserContributedProjects).to receive(:track).with(event)
event.save
end
+
+ it 'does not call UserContributedProjects.track if its not yet available' do
+ expect(UserContributedProjects).to receive(:available?).and_return(false)
+ expect(UserContributedProjects).not_to receive(:track)
+ event.save
+ end
end
end