summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/plugin_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/plugin_spec.rb')
-rw-r--r--spec/lib/gitlab/plugin_spec.rb57
1 files changed, 47 insertions, 10 deletions
diff --git a/spec/lib/gitlab/plugin_spec.rb b/spec/lib/gitlab/plugin_spec.rb
index a8ddd774f3f..5d9f6d04caa 100644
--- a/spec/lib/gitlab/plugin_spec.rb
+++ b/spec/lib/gitlab/plugin_spec.rb
@@ -3,22 +3,59 @@
require 'spec_helper'
describe Gitlab::Plugin do
+ let(:plugin) { Rails.root.join('plugins', 'test.rb') }
+ let(:tmp_file) { Tempfile.new('plugin-dump') }
+
+ let(:plugin_source) do
+ <<~EOS
+ #!/usr/bin/env ruby
+ x = STDIN.read
+ File.write('#{tmp_file.path}', x)
+ EOS
+ end
+
+ context 'with plugins present' do
+ before do
+ File.write(plugin, plugin_source)
+ end
+
+ after do
+ FileUtils.rm(plugin)
+ end
+
+ describe '.any?' do
+ it 'returns true' do
+ expect(described_class.any?).to be true
+ end
+ end
+
+ describe '.files?' do
+ it 'returns a list of plugins' do
+ expect(described_class.files).to match_array([plugin.to_s])
+ end
+ end
+ end
+
+ context 'without any plugins' do
+ describe '.any?' do
+ it 'returns false' do
+ expect(described_class.any?).to be false
+ end
+ end
+
+ describe '.files' do
+ it 'returns an empty list' do
+ expect(described_class.files).to be_empty
+ end
+ end
+ end
+
describe '.execute' do
let(:data) { Gitlab::DataBuilder::Push::SAMPLE_DATA }
- let(:plugin) { Rails.root.join('plugins', 'test.rb') }
- let(:tmp_file) { Tempfile.new('plugin-dump') }
let(:result) { described_class.execute(plugin.to_s, data) }
let(:success) { result.first }
let(:message) { result.last }
- let(:plugin_source) do
- <<~EOS
- #!/usr/bin/env ruby
- x = STDIN.read
- File.write('#{tmp_file.path}', x)
- EOS
- end
-
before do
File.write(plugin, plugin_source)
end