Commit 28f9a4dc authored by Mark Chao's avatar Mark Chao Committed by Nick Thomas

Resolve "Extract EE specific files/lines for lib/gitlab/slash_commands"

parent a02533bb
module EE
module Gitlab
module SlashCommands
module Command
extend ActiveSupport::Concern
class_methods do
extend ::Gitlab::Utils::Override
override :commands
def commands
super.concat(
[
::Gitlab::SlashCommands::Run
]
)
end
end
end
end
end
end
module EE
module Gitlab
module SlashCommands
module Presenters
module IssueBase
extend ::Gitlab::Utils::Override
override :fields
def fields
super.concat(
[
{
title: "Weight",
value: resource.weight? ? resource.weight : "_None_",
short: true
}
]
)
end
end
end
end
end
end
...@@ -16,7 +16,7 @@ module Gitlab ...@@ -16,7 +16,7 @@ module Gitlab
end end
def commands def commands
Gitlab::SlashCommands::Command::COMMANDS Gitlab::SlashCommands::Command.commands
end end
end end
end end
......
require 'spec_helper'
describe Gitlab::SlashCommands::Command do
describe '.commands' do
it 'includes EE specific commands' do
expect(described_class.commands).to include(Gitlab::SlashCommands::Run)
end
end
end
require 'spec_helper'
describe Gitlab::SlashCommands::Presenters::IssueShow do
let(:project) { create(:project) }
let(:attachment) { subject[:attachments].first }
subject { described_class.new(issue).present }
context 'issue with issue weight' do
let(:issue) { create(:issue, project: project, weight: 3) }
let(:weight_attachment) { attachment[:fields].find { |a| a[:title] == "Weight" } }
it 'shows the weight' do
expect(weight_attachment).not_to be_nil
expect(weight_attachment[:value]).to be(3)
end
end
end
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class Command < BaseCommand class Command < BaseCommand
COMMANDS = [ prepend EE::Gitlab::SlashCommands::Command
Gitlab::SlashCommands::IssueShow,
Gitlab::SlashCommands::IssueNew, def self.commands
Gitlab::SlashCommands::IssueSearch, [
Gitlab::SlashCommands::IssueMove, Gitlab::SlashCommands::IssueShow,
Gitlab::SlashCommands::Deploy, Gitlab::SlashCommands::IssueNew,
Gitlab::SlashCommands::Run Gitlab::SlashCommands::IssueSearch,
].freeze Gitlab::SlashCommands::IssueMove,
Gitlab::SlashCommands::Deploy
]
end
def execute def execute
command, match = match_command command, match = match_command
...@@ -38,7 +41,7 @@ module Gitlab ...@@ -38,7 +41,7 @@ module Gitlab
private private
def available_commands def available_commands
COMMANDS.select do |klass| self.class.commands.keep_if do |klass|
klass.available?(project) klass.available?(project)
end end
end end
......
...@@ -2,6 +2,8 @@ module Gitlab ...@@ -2,6 +2,8 @@ module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
module IssueBase module IssueBase
prepend EE::Gitlab::SlashCommands::Presenters::IssueBase
def color(issuable) def color(issuable)
issuable.open? ? '#38ae67' : '#d22852' issuable.open? ? '#38ae67' : '#d22852'
end end
...@@ -34,11 +36,6 @@ module Gitlab ...@@ -34,11 +36,6 @@ module Gitlab
title: "Labels", title: "Labels",
value: resource.labels.any? ? resource.label_names.join(', ') : "_None_", value: resource.labels.any? ? resource.label_names.join(', ') : "_None_",
short: true short: true
},
{
title: "Weight",
value: resource.weight? ? resource.weight : "_None_",
short: true
} }
] ]
end end
......
...@@ -49,14 +49,4 @@ describe Gitlab::SlashCommands::Presenters::IssueShow do ...@@ -49,14 +49,4 @@ describe Gitlab::SlashCommands::Presenters::IssueShow do
expect(attachment[:text]).to start_with("**Open**") expect(attachment[:text]).to start_with("**Open**")
end end
end end
context 'issue with issue weight' do
let(:issue) { create(:issue, project: project, weight: 3) }
let(:weight_attachment) { subject[:attachments].first[:fields].find { |a| a[:title] == "Weight" } }
it 'shows the weight' do
expect(weight_attachment).not_to be_nil
expect(weight_attachment[:value]).to be(3)
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment