diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-17 22:51:43 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-17 22:51:43 +0300 |
commit | 2d87556847931bd146eddaafdee48c2f8954326c (patch) | |
tree | a46a490d98f4a14e0fec210453d1643e51bdf062 /spec | |
parent | a90a201d0ee3c9e33cc04075ac8a2509c1d2acc9 (diff) | |
download | gitlab-ce-2d87556847931bd146eddaafdee48c2f8954326c.tar.gz |
Remove rails observers from application
Diffstat (limited to 'spec')
30 files changed, 15 insertions, 180 deletions
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 1aba40966c4..82da19746f8 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -47,20 +47,16 @@ describe "Admin::Users", feature: true do it "should call send mail" do Notify.should_receive(:new_user_email) - User.observers.enable :user_observer do - click_button "Create user" - end + click_button "Create user" end it "should send valid email to user with email & password" do - User.observers.enable :user_observer do - click_button "Create user" - user = User.last - email = ActionMailer::Base.deliveries.last - email.subject.should have_content("Account was created") - email.text_part.body.should have_content(user.email) - email.text_part.body.should have_content('password') - end + click_button "Create user" + user = User.last + email = ActionMailer::Base.deliveries.last + email.subject.should have_content("Account was created") + email.text_part.body.should have_content(user.email) + email.text_part.body.should have_content('password') end end diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb index e8364bbb962..bdf7b59114b 100644 --- a/spec/features/profile_spec.rb +++ b/spec/features/profile_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe "Profile account page", feature: true do - before(:each) { enable_observers } - after(:each) {disable_observers} let(:user) { create(:user) } before do diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 1e24782c39a..524c4d5fa21 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe "Projects", feature: true do - before(:each) { enable_observers } - after(:each) {disable_observers} before { login_as :user } describe "DELETE /projects/:id" do diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index f12eb124296..cce9f06cb69 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -2,7 +2,6 @@ require 'spec_helper' describe "Search", feature: true do before do - ActiveRecord::Base.observers.enable(:user_observer) login_as :user @project = create(:project, namespace: @user.namespace) @project.team << [@user, :reporter] diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index a2519fbd684..93eae5a9ebd 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -27,9 +27,6 @@ require 'spec_helper' describe Project do - before { enable_observers } - after { disable_observers } - describe "Associations" do it { should belong_to(:group) } it { should belong_to(:namespace) } diff --git a/spec/models/system_hook_spec.rb b/spec/models/system_hook_spec.rb index 47d6d861d70..51aaccf2267 100644 --- a/spec/models/system_hook_spec.rb +++ b/spec/models/system_hook_spec.rb @@ -19,8 +19,6 @@ require "spec_helper" describe SystemHook do describe "execute" do - before(:each) { ActiveRecord::Base.observers.enable(:all) } - before(:each) do @system_hook = create(:system_hook) WebMock.stub_request(:post, @system_hook.url) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4e0ebb584d1..0a665b7defb 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -145,7 +145,6 @@ describe User do describe 'projects' do before do - ActiveRecord::Base.observers.enable(:user_observer) @user = create :user @project = create :project, namespace: @user.namespace @project_2 = create :project, group: create(:group) # Grant MASTER access to the user @@ -168,7 +167,6 @@ describe User do describe 'groups' do before do - ActiveRecord::Base.observers.enable(:user_observer) @user = create :user @group = create :group @group.add_owner(@user) @@ -181,7 +179,6 @@ describe User do describe 'group multiple owners' do before do - ActiveRecord::Base.observers.enable(:user_observer) @user = create :user @user2 = create :user @group = create :group @@ -195,7 +192,6 @@ describe User do describe 'namespaced' do before do - ActiveRecord::Base.observers.enable(:user_observer) @user = create :user @project = create :project, namespace: @user.namespace end @@ -339,7 +335,7 @@ describe User do user.all_ssh_keys.should include(key.key) end end - + describe :avatar_type do let(:user) { create(:user) } diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb deleted file mode 100644 index b024465e8c3..00000000000 --- a/spec/observers/users_project_observer_spec.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'spec_helper' - -describe UsersProjectObserver do - before(:each) { enable_observers } - after(:each) { disable_observers } - - let(:user) { create(:user) } - let(:project) { create(:project) } - subject { UsersProjectObserver.instance } - before { subject.stub(notification: double('NotificationService').as_null_object) } - - describe "#after_update" do - before do - @users_project = create :users_project - end - - it "should called when UsersProject updated" do - subject.should_receive(:after_update) - @users_project.update_attribute(:project_access, UsersProject::MASTER) - end - - it "should send email to user" do - subject.should_receive(:notification) - @users_project.update_attribute(:project_access, UsersProject::OWNER) - end - - it "should not called after UsersProject destroyed" do - subject.should_not_receive(:after_update) - @users_project.destroy - end - end - - describe "#after_destroy" do - before do - @users_project = create :users_project - end - - it "should called when UsersProject destroyed" do - subject.should_receive(:after_destroy) - @users_project.destroy - end - - it "should create new event" do - Event.should_receive(:create) - @users_project.destroy - end - end - - describe "#after_create" do - it "should send email to user" do - subject.should_receive(:notification) - Event.stub(create: true) - - create(:users_project) - end - - it "should create new event" do - Event.should_receive(:create) - - create(:users_project) - end - end -end diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index 72589da5d40..b145e620122 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -3,8 +3,6 @@ require 'mime/types' describe API::API, api: true do include ApiHelpers - before(:each) { enable_observers } - after(:each) {disable_observers} let(:user) { create(:user) } let(:user2) { create(:user) } diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 165276d1435..b56269d275d 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -3,9 +3,6 @@ require 'mime/types' describe API::API, api: true do include ApiHelpers - before(:each) { enable_observers } - after(:each) {disable_observers} - let(:user) { create(:user) } let(:user2) { create(:user) } let!(:project) { create(:project, creator_id: user.id) } diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb index edfe935d985..e84122f2fbc 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -2,9 +2,6 @@ require 'spec_helper' describe API::API, api: true do include ApiHelpers - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - let(:user) { create(:user) } let!(:project) { create(:project, namespace: user.namespace ) } before { project.team << [user, :developer] } diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 8797c3fbbbf..dbe8043c633 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -2,9 +2,6 @@ require 'spec_helper' describe API::API, api: true do include ApiHelpers - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - let(:user) { create(:user) } let(:key) { create(:key, user: user) } let(:project) { create(:project) } diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index e62bc844352..dff7f20cb32 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -2,9 +2,6 @@ require 'spec_helper' describe API::API, api: true do include ApiHelpers - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - let(:user) { create(:user) } let!(:project) { create(:project, namespace: user.namespace ) } let!(:issue) { create(:issue, author: user, assignee: user, project: project) } diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 2fb3684fdf0..3611d9d6dc3 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -2,8 +2,6 @@ require "spec_helper" describe API::API, api: true do include ApiHelpers - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } let(:user) { create(:user) } let!(:project) {create(:project, creator_id: user.id, namespace: user.namespace) } let!(:merge_request) { create(:merge_request, :simple, author: user, assignee: user, source_project: project, target_project: project, title: "Test") } diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb index 0d2740c5acf..f0619a1c801 100644 --- a/spec/requests/api/milestones_spec.rb +++ b/spec/requests/api/milestones_spec.rb @@ -2,9 +2,6 @@ require 'spec_helper' describe API::API, api: true do include ApiHelpers - before(:each) { enable_observers } - after(:each) {disable_observers} - let(:user) { create(:user) } let!(:project) { create(:project, namespace: user.namespace ) } let!(:milestone) { create(:milestone, project: project) } @@ -92,9 +89,6 @@ describe API::API, api: true do end describe "PUT /projects/:id/milestones/:milestone_id to test observer on close" do - before { enable_observers } - after { disable_observers } - it "should create an activity event when an milestone is closed" do Event.should_receive(:create) diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb index 2de7d1e23c3..d9d52468b15 100644 --- a/spec/requests/api/namespaces_spec.rb +++ b/spec/requests/api/namespaces_spec.rb @@ -2,9 +2,6 @@ require 'spec_helper' describe API::API, api: true do include ApiHelpers - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - let(:admin) { create(:admin) } let!(:group1) { create(:group) } let!(:group2) { create(:group) } diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index 2875db04ee4..7aa53787aed 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -2,9 +2,6 @@ require 'spec_helper' describe API::API, api: true do include ApiHelpers - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - let(:user) { create(:user) } let!(:project) { create(:project, namespace: user.namespace ) } let!(:issue) { create(:issue, project: project, author: user) } @@ -128,14 +125,10 @@ describe API::API, api: true do end describe "POST /projects/:id/noteable/:noteable_id/notes to test observer on create" do - before { enable_observers } - after { disable_observers } - it "should create an activity event when an issue note is created" do Event.should_receive(:create) post api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!' end end - end diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb index 6e281f5a43e..cdb5e3d0612 100644 --- a/spec/requests/api/project_hooks_spec.rb +++ b/spec/requests/api/project_hooks_spec.rb @@ -2,9 +2,6 @@ require 'spec_helper' describe API::API, 'ProjectHooks', api: true do include ApiHelpers - before(:each) { enable_observers } - after(:each) { disable_observers } - let(:user) { create(:user) } let(:user3) { create(:user) } let!(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } diff --git a/spec/requests/api/project_members_spec.rb b/spec/requests/api/project_members_spec.rb index 032f850010c..3c480c2ac4b 100644 --- a/spec/requests/api/project_members_spec.rb +++ b/spec/requests/api/project_members_spec.rb @@ -2,9 +2,6 @@ require 'spec_helper' describe API::API, api: true do include ApiHelpers - before(:each) { enable_observers } - after(:each) { disable_observers } - let(:user) { create(:user) } let(:user2) { create(:user) } let(:user3) { create(:user) } diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 415735091c3..41841e855fd 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -2,9 +2,6 @@ require 'spec_helper' describe API::API, api: true do include ApiHelpers - before(:each) { enable_observers } - after(:each) { disable_observers } - let(:user) { create(:user) } let(:user2) { create(:user) } let(:user3) { create(:user) } diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index 5afb3bddcb7..94850d0f1ae 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -3,9 +3,6 @@ require 'mime/types' describe API::API, api: true do include ApiHelpers - before(:each) { enable_observers } - after(:each) {disable_observers} - let(:user) { create(:user) } let(:user2) { create(:user) } let!(:project) { create(:project, creator_id: user.id) } diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index 684f8615999..f883c9e028a 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -2,9 +2,6 @@ require "spec_helper" describe API::API, api: true do include ApiHelpers - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - let(:user) { create(:user) } let(:project) {create(:project, creator_id: user.id, namespace: user.namespace) } diff --git a/spec/services/issues/bulk_update_context_spec.rb b/spec/services/issues/bulk_update_context_spec.rb index 548109a8450..f4c9148f1a3 100644 --- a/spec/services/issues/bulk_update_context_spec.rb +++ b/spec/services/issues/bulk_update_context_spec.rb @@ -1,12 +1,9 @@ require 'spec_helper' describe Issues::BulkUpdateService do - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - let(:issue) { create(:issue, project: @project) - } + } before do @user = create :user @@ -23,7 +20,7 @@ describe Issues::BulkUpdateService do @issues = 5.times.collect do create(:issue, project: @project) end - @params = { + @params = { update: { status: 'closed', issues_ids: @issues.map(&:id) @@ -48,7 +45,7 @@ describe Issues::BulkUpdateService do @issues = 5.times.collect do create(:closed_issue, project: @project) end - @params = { + @params = { update: { status: 'reopen', issues_ids: @issues.map(&:id) @@ -71,7 +68,7 @@ describe Issues::BulkUpdateService do before do @new_assignee = create :user - @params = { + @params = { update: { issues_ids: [issue.id], assignee_id: @new_assignee.id @@ -93,7 +90,7 @@ describe Issues::BulkUpdateService do before do @milestone = create :milestone - @params = { + @params = { update: { issues_ids: [issue.id], milestone_id: @milestone.id diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index 0eac6bed74b..3dac0539031 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -1,9 +1,6 @@ require 'spec_helper' describe Projects::CreateService do - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - describe :create_by_user do before do @user = create :user diff --git a/spec/services/projects/image_service_spec.rb b/spec/services/projects/image_service_spec.rb index 070c21698cf..23c4e227ae3 100644 --- a/spec/services/projects/image_service_spec.rb +++ b/spec/services/projects/image_service_spec.rb @@ -1,9 +1,6 @@ require 'spec_helper' describe Projects::ImageService do - before(:each) { enable_observers } - after(:each) { disable_observers } - describe 'Image service' do before do @user = create :user diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 563a8b0c01c..2508dfc4565 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -1,9 +1,6 @@ require 'spec_helper' describe Projects::TransferService do - before(:each) { enable_observers } - after(:each) {disable_observers} - let(:user) { create(:user) } let(:group) { create(:group) } let(:group2) { create(:group) } diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb index 1854c0d8233..bb0470e3771 100644 --- a/spec/services/projects/update_service_spec.rb +++ b/spec/services/projects/update_service_spec.rb @@ -1,9 +1,6 @@ require 'spec_helper' describe Projects::UpdateService do - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - describe :update_by_user do before do @user = create :user diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 65a641bcf12..2181238ae9f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -43,7 +43,7 @@ RSpec.configure do |config| # instead of true. config.before(:suite) do - TestEnv.init(observers: false, init_repos: true, repos: false) + TestEnv.init(init_repos: true, repos: false) end config.before(:each) do TestEnv.setup_stubs diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index cc0ec2f4e3d..7713e9f17d7 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -3,9 +3,7 @@ module LoginHelpers # # role - User role (e.g., :admin, :user) def login_as(role) - ActiveRecord::Base.observers.enable(:user_observer) do - @user = create(role) - end + @user = create(role) login_with(@user) end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index b1bb65a836e..85059dfa9e9 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -17,14 +17,6 @@ module TestEnv def init(opts = {}) RSpec::Mocks::setup(self) - # Disable observers to improve test speed - # - # You can enable it in whole test case where needed by next string: - # - # before(:each) { enable_observers } - # - disable_observers if opts[:observers] == false - # Disable mailer for spinach tests disable_mailer if opts[:mailer] == false setup_stubs @@ -33,14 +25,6 @@ module TestEnv setup_test_repos(opts) if opts[:repos] == true end - def enable_observers - ActiveRecord::Base.observers.enable(:all) - end - - def disable_observers - ActiveRecord::Base.observers.disable(:all) - end - def disable_mailer NotificationService.any_instance.stub(mailer: double.as_null_object) end @@ -89,10 +73,6 @@ module TestEnv Repository.any_instance.stub( size: 12.45 ) - - BaseObserver.any_instance.stub( - current_user: double("current_user", id: 1) - ) end def clear_repo_dir(namespace, name) |