Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Move webhook specs to correct location

Jan Sandbrinkb1f11e805634
diff --git a/modules/webhooks/spec/controllers/webhooks_controller_spec.rb b/modules/webhooks/spec/controllers/webhooks_controller_spec.rb
index bc1c6649995..dcb6d5fcb55 100644
--- a/modules/webhooks/spec/controllers/webhooks_controller_spec.rb
+++ b/modules/webhooks/spec/controllers/webhooks_controller_spec.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require_relative "../spec_helper"
+require "spec_helper"
RSpec.describe Webhooks::Incoming::HooksController do
let(:hook) { double(OpenProject::Webhooks::Hook) }
diff --git a/modules/webhooks/spec/lib/hook_spec.rb b/modules/webhooks/spec/lib/open_project/webhooks/hook_spec.rb
similarity index 87%
rename from modules/webhooks/spec/lib/hook_spec.rb
rename to modules/webhooks/spec/lib/open_project/webhooks/hook_spec.rb
index a642037f62c..7abbd5339e1 100644
--- a/modules/webhooks/spec/lib/hook_spec.rb
+++ b/modules/webhooks/spec/lib/open_project/webhooks/hook_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -26,11 +28,11 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require_relative "../spec_helper"
+require "spec_helper"
RSpec.describe OpenProject::Webhooks::Hook do
describe "#relative_url" do
- let(:hook) { OpenProject::Webhooks::Hook.new("myhook") }
+ let(:hook) { described_class.new("myhook") }
it "returns the correct URL" do
expect(hook.relative_url).to eql("webhooks/myhook")
@@ -38,14 +40,11 @@ RSpec.describe OpenProject::Webhooks::Hook do
end
describe "#handle" do
- let(:probe) { lambda {} }
- let(:hook) { OpenProject::Webhooks::Hook.new("myhook", &probe) }
-
- before do
- expect(probe).to receive(:call).with(hook, 1, 2, 3)
- end
+ let(:probe) { -> {} }
+ let(:hook) { described_class.new("myhook", &probe) }
it "executes the callback with the correct parameters" do
+ expect(probe).to receive(:call).with(hook, 1, 2, 3)
hook.handle(1, 2, 3)
end
end
diff --git a/modules/webhooks/spec/lib/webhooks_spec.rb b/modules/webhooks/spec/lib/open_project/webhooks_spec.rb
similarity index 74%
rename from modules/webhooks/spec/lib/webhooks_spec.rb
rename to modules/webhooks/spec/lib/open_project/webhooks_spec.rb
index 5aa06e03cfa..3eed852b438 100644
--- a/modules/webhooks/spec/lib/webhooks_spec.rb
+++ b/modules/webhooks/spec/lib/open_project/webhooks_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -26,28 +28,28 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require_relative "../spec_helper"
+require "spec_helper"
RSpec.describe OpenProject::Webhooks do
describe ".register_hook" do
after do
- OpenProject::Webhooks.unregister_hook("testhook1")
+ described_class.unregister_hook("testhook1")
end
it "succeeds" do
- OpenProject::Webhooks.register_hook("testhook1") {}
+ described_class.register_hook("testhook1") {}
end
end
describe ".find" do
- let!(:hook) { OpenProject::Webhooks.register_hook("testhook3") {} }
+ let!(:hook) { described_class.register_hook("testhook3") {} }
after do
- OpenProject::Webhooks.unregister_hook("testhook3")
+ described_class.unregister_hook("testhook3")
end
it "succeeds" do
- expect(OpenProject::Webhooks.find("testhook3")).to equal(hook)
+ expect(described_class.find("testhook3")).to equal(hook)
end
end
@@ -55,12 +57,12 @@ RSpec.describe OpenProject::Webhooks do
let(:probe) { lambda {} }
before do
- OpenProject::Webhooks.register_hook("testhook2", &probe)
+ described_class.register_hook("testhook2", &probe)
end
it "results in the hook no longer being found" do
- OpenProject::Webhooks.unregister_hook("testhook2")
- expect(OpenProject::Webhooks.find("testhook2")).to be_nil
+ described_class.unregister_hook("testhook2")
+ expect(described_class.find("testhook2")).to be_nil
end
end
end
diff --git a/modules/webhooks/spec/spec_helper.rb b/modules/webhooks/spec/spec_helper.rb
deleted file mode 100644
index 6d21964f56e..00000000000
--- a/modules/webhooks/spec/spec_helper.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-require "spec_helper"