summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Procfile2
-rw-r--r--config/initializers/4_sidekiq.rb (renamed from config/initializers/4_resque.rb)0
-rw-r--r--features/steps/admin/admin_active_tab.rb2
-rw-r--r--features/support/env.rb2
-rwxr-xr-xlib/hooks/post-receive1
-rw-r--r--lib/tasks/gitlab/check.rake6
-rw-r--r--spec/models/system_hook_spec.rb25
-rw-r--r--spec/observers/issue_observer_spec.rb16
-rw-r--r--spec/observers/merge_request_observer_spec.rb7
-rw-r--r--spec/observers/note_observer_spec.rb23
-rw-r--r--spec/observers/user_observer_spec.rb16
-rw-r--r--spec/requests/admin/admin_users_spec.rb6
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/workers/post_receive_spec.rb8
14 files changed, 48 insertions, 68 deletions
diff --git a/Procfile b/Procfile
index eed515582bc..d3b3e051e88 100644
--- a/Procfile
+++ b/Procfile
@@ -1,2 +1,2 @@
web: bundle exec rails s -p $PORT
-worker: bundle exec rake sidekiq:start
+worker: bundle exec sidekiq -q post_receive,mailer,system_hook,common,default
diff --git a/config/initializers/4_resque.rb b/config/initializers/4_sidekiq.rb
index 6abe6e74fa0..6abe6e74fa0 100644
--- a/config/initializers/4_resque.rb
+++ b/config/initializers/4_sidekiq.rb
diff --git a/features/steps/admin/admin_active_tab.rb b/features/steps/admin/admin_active_tab.rb
index 05a9a686e01..48ec7bac0d6 100644
--- a/features/steps/admin/admin_active_tab.rb
+++ b/features/steps/admin/admin_active_tab.rb
@@ -28,6 +28,6 @@ class AdminActiveTab < Spinach::FeatureSteps
end
Then 'the active main tab should be Resque' do
- ensure_active_main_tab('Resque')
+ ensure_active_main_tab('Background Jobs')
end
end
diff --git a/features/support/env.rb b/features/support/env.rb
index 72531718e0c..be10ad1b8b9 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -6,6 +6,8 @@ require './config/environment'
require 'rspec'
require 'database_cleaner'
require 'spinach/capybara'
+require 'sidekiq/testing/inline'
+
%w(gitolite_stub stubbed_repository valid_commit).each do |f|
require Rails.root.join('spec', 'support', f)
diff --git a/lib/hooks/post-receive b/lib/hooks/post-receive
index ebd9e1a028a..6944d3e3f72 100755
--- a/lib/hooks/post-receive
+++ b/lib/hooks/post-receive
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
+# Version 4.1
# This file was placed here by GitLab. It makes sure that your pushed commits
# will be processed properly.
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 252b508609a..db181cb9a96 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -871,7 +871,7 @@ namespace :gitlab do
namespace :resque do
- desc "GITLAB | Check the configuration of Resque"
+ desc "GITLAB | Check the configuration of Sidekiq"
task check: :environment do
warn_user_is_not_gitlab
start_checking "Resque"
@@ -888,7 +888,7 @@ namespace :gitlab do
def check_resque_running
print "Running? ... "
- if run_and_match("ps aux | grep -i resque", /resque-[\d\.]+:.+$/)
+ if run_and_match("ps aux | grep -i sidekiq", /sidekiq-[\d\.]+:.+$/)
puts "yes".green
else
puts "no".red
@@ -899,7 +899,7 @@ namespace :gitlab do
)
for_more_information(
see_installation_guide_section("Install Init Script"),
- "see log/resque.log for possible errors"
+ "see log/sidekiq.log for possible errors"
)
fix_and_rerun
end
diff --git a/spec/models/system_hook_spec.rb b/spec/models/system_hook_spec.rb
index cc358a2ed3b..a9ed6a5fa7c 100644
--- a/spec/models/system_hook_spec.rb
+++ b/spec/models/system_hook_spec.rb
@@ -23,41 +23,31 @@ describe SystemHook do
end
it "project_create hook" do
- with_resque do
- project = create(:project)
- end
+ project = create(:project)
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once
end
it "project_destroy hook" do
project = create(:project)
- with_resque do
- project.destroy
- end
+ project.destroy
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_destroy/).once
end
it "user_create hook" do
- with_resque do
- create(:user)
- end
+ create(:user)
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once
end
it "user_destroy hook" do
user = create(:user)
- with_resque do
- user.destroy
- end
+ user.destroy
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_destroy/).once
end
it "project_create hook" do
user = create(:user)
project = create(:project)
- with_resque do
- project.team << [user, :master]
- end
+ project.team << [user, :master]
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once
end
@@ -65,11 +55,8 @@ describe SystemHook do
user = create(:user)
project = create(:project)
project.team << [user, :master]
- with_resque do
- project.users_projects.clear
- end
+ project.users_projects.clear
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
end
end
-
end
diff --git a/spec/observers/issue_observer_spec.rb b/spec/observers/issue_observer_spec.rb
index bbffbd342db..700c9a3a69b 100644
--- a/spec/observers/issue_observer_spec.rb
+++ b/spec/observers/issue_observer_spec.rb
@@ -21,8 +21,7 @@ describe IssueObserver do
end
it 'sends an email to the assignee' do
- Notify.should_receive(:new_issue_email).with(issue.id).
- and_return(double(deliver: true))
+ Notify.should_receive(:new_issue_email).with(issue.id)
subject.after_create(issue)
end
@@ -71,6 +70,7 @@ describe IssueObserver do
context 'a status "closed"' do
it 'note is created if the issue is being closed' do
issue.should_receive(:is_being_closed?).and_return(true)
+ Notify.should_receive(:issue_status_changed_email).twice
Note.should_receive(:create_status_change_note).with(issue, some_user, 'closed')
subject.after_update(issue)
@@ -85,7 +85,7 @@ describe IssueObserver do
it 'notification is delivered if the issue being closed' do
issue.stub(:is_being_closed?).and_return(true)
- Notify.should_receive(:issue_status_changed_email).twice.and_return(stub(deliver: true))
+ Notify.should_receive(:issue_status_changed_email).twice
Note.should_receive(:create_status_change_note).with(issue, some_user, 'closed')
subject.after_update(issue)
@@ -104,7 +104,7 @@ describe IssueObserver do
issue_without_assignee.stub(:is_being_reassigned?).and_return(false)
issue_without_assignee.stub(:is_being_closed?).and_return(true)
issue_without_assignee.stub(:is_being_reopened?).and_return(false)
- Notify.should_receive(:issue_status_changed_email).once.and_return(stub(deliver: true))
+ Notify.should_receive(:issue_status_changed_email).once
Note.should_receive(:create_status_change_note).with(issue_without_assignee, some_user, 'closed')
subject.after_update(issue_without_assignee)
@@ -113,6 +113,7 @@ describe IssueObserver do
context 'a status "reopened"' do
it 'note is created if the issue is being reopened' do
+ Notify.should_receive(:issue_status_changed_email).twice
issue.should_receive(:is_being_reopened?).and_return(true)
Note.should_receive(:create_status_change_note).with(issue, some_user, 'reopened')
@@ -128,7 +129,7 @@ describe IssueObserver do
it 'notification is delivered if the issue being reopened' do
issue.stub(:is_being_reopened?).and_return(true)
- Notify.should_receive(:issue_status_changed_email).twice.and_return(stub(deliver: true))
+ Notify.should_receive(:issue_status_changed_email).twice
Note.should_receive(:create_status_change_note).with(issue, some_user, 'reopened')
subject.after_update(issue)
@@ -147,7 +148,7 @@ describe IssueObserver do
issue_without_assignee.stub(:is_being_reassigned?).and_return(false)
issue_without_assignee.stub(:is_being_closed?).and_return(false)
issue_without_assignee.stub(:is_being_reopened?).and_return(true)
- Notify.should_receive(:issue_status_changed_email).once.and_return(stub(deliver: true))
+ Notify.should_receive(:issue_status_changed_email).once
Note.should_receive(:create_status_change_note).with(issue_without_assignee, some_user, 'reopened')
subject.after_update(issue_without_assignee)
@@ -164,8 +165,7 @@ describe IssueObserver do
end
def it_sends_a_reassigned_email_to(recipient)
- Notify.should_receive(:reassigned_issue_email).with(recipient, issue.id, previous_assignee.id).
- and_return(double(deliver: true))
+ Notify.should_receive(:reassigned_issue_email).with(recipient, issue.id, previous_assignee.id)
end
def it_does_not_send_a_reassigned_email_to(recipient)
diff --git a/spec/observers/merge_request_observer_spec.rb b/spec/observers/merge_request_observer_spec.rb
index 6b15be96630..4841bf88fc5 100644
--- a/spec/observers/merge_request_observer_spec.rb
+++ b/spec/observers/merge_request_observer_spec.rb
@@ -21,9 +21,7 @@ describe MergeRequestObserver do
end
it 'sends an email to the assignee' do
- Notify.should_receive(:new_merge_request_email).with(mr.id).
- and_return(double(deliver: true))
-
+ Notify.should_receive(:new_merge_request_email).with(mr.id)
subject.after_create(mr)
end
@@ -158,8 +156,7 @@ describe MergeRequestObserver do
end
def it_sends_a_reassigned_email_to(recipient)
- Notify.should_receive(:reassigned_merge_request_email).with(recipient, mr.id, previous_assignee.id).
- and_return(double(deliver: true))
+ Notify.should_receive(:reassigned_merge_request_email).with(recipient, mr.id, previous_assignee.id)
end
def it_does_not_send_a_reassigned_email_to(recipient)
diff --git a/spec/observers/note_observer_spec.rb b/spec/observers/note_observer_spec.rb
index 7dfa9f772e9..73da2e146cb 100644
--- a/spec/observers/note_observer_spec.rb
+++ b/spec/observers/note_observer_spec.rb
@@ -4,7 +4,6 @@ describe NoteObserver do
subject { NoteObserver.instance }
let(:team_without_author) { (1..2).map { |n| double :user, id: n } }
- let(:delivery_success) { double deliver: true }
describe '#after_create' do
let(:note) { double :note }
@@ -45,13 +44,13 @@ describe NoteObserver do
note.stub(:id).and_return(42)
author = double :user, id: 1
note.stub(:commit_author).and_return(author)
- Notify.should_receive(:note_commit_email).and_return(delivery_success)
+ Notify.should_receive(:note_commit_email)
subject.after_create(note)
end
it 'does not notify the author of a commit when not flagged to notify the author' do
- Notify.should_not_receive(:note_commit_email)
+ notify.should_not_receive(:note_commit_email)
subject.after_create(note)
end
@@ -71,28 +70,28 @@ describe NoteObserver do
context 'notifies team of a new note on' do
it 'a commit' do
note.stub(:noteable_type).and_return('Commit')
- Notify.should_receive(:note_commit_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_commit_email).twice
subject.send(:notify_team, note)
end
it 'an issue' do
note.stub(:noteable_type).and_return('Issue')
- Notify.should_receive(:note_issue_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_issue_email).twice
subject.send(:notify_team, note)
end
it 'a wiki page' do
note.stub(:noteable_type).and_return('Wiki')
- Notify.should_receive(:note_wiki_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_wiki_email).twice
subject.send(:notify_team, note)
end
it 'a merge request' do
note.stub(:noteable_type).and_return('MergeRequest')
- Notify.should_receive(:note_merge_request_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_merge_request_email).twice
subject.send(:notify_team, note)
end
@@ -100,16 +99,16 @@ describe NoteObserver do
it 'a wall' do
# Note: wall posts have #noteable_type of nil
note.stub(:noteable_type).and_return(nil)
- Notify.should_receive(:note_wall_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_wall_email).twice
subject.send(:notify_team, note)
end
end
it 'does nothing for a new note on a snippet' do
- note.stub(:noteable_type).and_return('Snippet')
+ note.stub(:noteable_type).and_return('Snippet')
- subject.send(:notify_team, note).should be_nil
+ subject.send(:notify_team, note).should be_nil
end
end
@@ -125,4 +124,8 @@ describe NoteObserver do
subject.send(:team_without_note_author, note).should == team_without_author
end
end
+
+ def notify
+ Notify
+ end
end
diff --git a/spec/observers/user_observer_spec.rb b/spec/observers/user_observer_spec.rb
index befb980fdcb..bffa5fcfd69 100644
--- a/spec/observers/user_observer_spec.rb
+++ b/spec/observers/user_observer_spec.rb
@@ -10,24 +10,14 @@ describe UserObserver do
end
context 'when a new user is created' do
- let(:user) { double(:user, id: 42,
- password: 'P@ssword!',
- name: 'John',
- email: 'u@mail.local',
- username: 'root',
- create_namespace: true) }
- let(:notification) { double :notification }
-
it 'sends an email' do
- notification.should_receive(:deliver)
- Notify.should_receive(:new_user_email).with(user.id, user.password).and_return(notification)
-
- subject.after_create(user)
+ Notify.should_receive(:new_user_email)
+ create(:user)
end
it 'trigger logger' do
Gitlab::AppLogger.should_receive(:info)
- subject.after_create(user)
+ create(:user)
end
end
end
diff --git a/spec/requests/admin/admin_users_spec.rb b/spec/requests/admin/admin_users_spec.rb
index ca134c2d4f7..a66e85a34f9 100644
--- a/spec/requests/admin/admin_users_spec.rb
+++ b/spec/requests/admin/admin_users_spec.rb
@@ -41,7 +41,7 @@ describe "Admin::Users" do
end
it "should call send mail" do
- Notify.should_receive(:new_user_email).and_return(stub(deliver: true))
+ Notify.should_receive(:new_user_email)
User.observers.enable :user_observer do
click_button "Save"
@@ -50,9 +50,7 @@ describe "Admin::Users" do
it "should send valid email to user with email & password" do
User.observers.enable :user_observer do
- with_resque do
- click_button "Save"
- end
+ click_button "Save"
user = User.last
email = ActionMailer::Base.deliveries.last
email.subject.should have_content("Account was created")
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index edabcc33625..dbac3c54901 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,5 +1,6 @@
require 'simplecov' unless ENV['CI']
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
@@ -8,6 +9,7 @@ require 'capybara/rails'
require 'capybara/rspec'
require 'webmock/rspec'
require 'email_spec'
+require 'sidekiq/testing/inline'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb
index 26b461c3825..f408c89afdd 100644
--- a/spec/workers/post_receive_spec.rb
+++ b/spec/workers/post_receive_spec.rb
@@ -4,7 +4,7 @@ describe PostReceive do
context "as a resque worker" do
it "reponds to #perform" do
- PostReceive.should respond_to(:perform)
+ PostReceive.new.should respond_to(:perform)
end
end
@@ -15,7 +15,7 @@ describe PostReceive do
it "fetches the correct project" do
Project.should_receive(:find_with_namespace).with(project.path_with_namespace).and_return(project)
- PostReceive.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id)
+ PostReceive.new.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id)
end
it "does not run if the author is not in the project" do
@@ -24,7 +24,7 @@ describe PostReceive do
project.should_not_receive(:observe_push)
project.should_not_receive(:execute_hooks)
- PostReceive.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id).should be_false
+ PostReceive.new.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id).should be_false
end
it "asks the project to trigger all hooks" do
@@ -34,7 +34,7 @@ describe PostReceive do
project.should_receive(:update_merge_requests)
project.should_receive(:observe_push)
- PostReceive.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id)
+ PostReceive.new.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id)
end
end