Commit dd12de65 authored by nmilojevic1's avatar nmilojevic1

Add missing specs

- Fix measurement_enabled?
parent 2e5d01ac
......@@ -27,7 +27,7 @@ namespace :gitlab do
project_path: args.project_path,
username: args.username,
file_path: args.archive_path,
measurement_enabled: args.measurement_enabled
measurement_enabled: args.measurement_enabled == 'true'
).import
end
end
......@@ -39,7 +39,7 @@ class GitlabProjectImport
@file_path = opts.fetch(:file_path)
@namespace = Namespace.find_by_full_path(opts.fetch(:namespace_path))
@current_user = User.find_by_username(opts.fetch(:username))
@measurement_enabled = opts.fetch(:measurement_enabled || false)
@measurement_enabled = opts.fetch(:measurement_enabled)
end
def import
......@@ -119,7 +119,7 @@ class GitlabProjectImport
end
def measurement_enabled?
@measurement_enabled
@measurement_enabled != false
end
# We want to ensure that all Sidekiq jobs are executed
......
......@@ -6,7 +6,8 @@ describe 'gitlab:import_export:import rake task' do
let(:username) { 'root' }
let(:namespace_path) { username }
let!(:user) { create(:user, username: username) }
let(:task_params) { [username, namespace_path, project_name, archive_path] }
let(:measurement_enabled) { false }
let(:task_params) { [username, namespace_path, project_name, archive_path, measurement_enabled] }
let(:project) { Project.find_by_full_path("#{namespace_path}/#{project_name}") }
before do
......@@ -68,6 +69,34 @@ describe 'gitlab:import_export:import rake task' do
subject
end
context 'when measurement is enabled' do
let(:measurement_enabled) { true }
it 'prints measurement results' do
expect { subject }.to output(including('Measuring enabled...', 'Number of sql calls:', 'Total GC count:', 'Total GC count:')).to_stdout
end
end
context 'when measurement is not enabled' do
let(:measurement_enabled) { false }
it 'output measurement results' do
expect { subject }.to_not output(/Measuring enabled.../).to_stdout
end
end
context 'when measurement is not provided' do
let(:task_params) { [username, namespace_path, project_name, archive_path] }
it 'does not output measurement results' do
expect { subject }.not_to output(/Measuring enabled.../).to_stdout
end
it 'does not raise any exception' do
expect { subject }.not_to raise_error
end
end
end
context 'when project import is invalid' do
......
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