Make it possible to mix `Gitlab::Routing` in

This commit is contained in:
Grzegorz Bizon 2016-12-13 14:51:23 +01:00
parent 00970606d7
commit 84290a452d
3 changed files with 30 additions and 1 deletions

View File

@ -4,7 +4,7 @@ module Gitlab
# Base abstract class fore core status
#
class Core
include Gitlab::Routing.url_helpers
include Gitlab::Routing
include Gitlab::Allowable
attr_reader :subject, :user

View File

@ -1,5 +1,11 @@
module Gitlab
module Routing
extend ActiveSupport::Concern
included do
include Gitlab::Routing.url_helpers
end
# Returns the URL helpers Module.
#
# This method caches the output as Rails' "url_helpers" method creates an

View File

@ -0,0 +1,23 @@
require 'spec_helper'
describe Gitlab::Routing do
context 'when module is included' do
subject do
Class.new.include(described_class).new
end
it 'makes it possible to access url helpers' do
expect(subject).to respond_to(:namespace_project_path)
end
end
context 'when module is not included' do
subject do
Class.new.include(described_class.url_helpers).new
end
it 'exposes url helpers module through a method' do
expect(subject).to respond_to(:namespace_project_path)
end
end
end