Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-26 12:10:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-26 12:10:25 +0300
commite2cf652edb5e9d9fa9a081952070074c07bf651e (patch)
tree43df576f4a9287977a95b2e3b6128175c16b7298 /spec
parent5a61836cf3492bcf3c1f865de66c2f2e61e37866 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/concerns/onboarding/status_spec.rb10
-rw-r--r--spec/tasks/gitlab/audit_event_types/audit_event_types_rake_spec.rb43
-rw-r--r--spec/tasks/gitlab/audit_event_types/check_docs_task_spec.rb67
-rw-r--r--spec/tasks/gitlab/audit_event_types/compile_docs_task_spec.rb29
-rw-r--r--spec/views/registrations/welcome/show.html.haml_spec.rb1
5 files changed, 145 insertions, 5 deletions
diff --git a/spec/controllers/concerns/onboarding/status_spec.rb b/spec/controllers/concerns/onboarding/status_spec.rb
index 3f6e597a235..b14346dc052 100644
--- a/spec/controllers/concerns/onboarding/status_spec.rb
+++ b/spec/controllers/concerns/onboarding/status_spec.rb
@@ -9,13 +9,13 @@ RSpec.describe Onboarding::Status, feature_category: :onboarding do
let_it_be(:source) { member.group }
describe '#continue_full_onboarding?' do
- subject { described_class.new(nil).continue_full_onboarding? }
+ subject { described_class.new(nil, {}, user).continue_full_onboarding? }
it { is_expected.to eq(false) }
end
describe '#single_invite?' do
- subject { described_class.new(user).single_invite? }
+ subject { described_class.new(nil, nil, user).single_invite? }
context 'when there is only one member for the user' do
context 'when the member source exists' do
@@ -39,7 +39,7 @@ RSpec.describe Onboarding::Status, feature_category: :onboarding do
end
describe '#last_invited_member' do
- subject { described_class.new(user).last_invited_member }
+ subject { described_class.new(nil, nil, user).last_invited_member }
it { is_expected.to eq(member) }
@@ -57,7 +57,7 @@ RSpec.describe Onboarding::Status, feature_category: :onboarding do
end
describe '#last_invited_member_source' do
- subject { described_class.new(user).last_invited_member_source }
+ subject { described_class.new(nil, nil, user).last_invited_member_source }
context 'when a member exists' do
it { is_expected.to eq(source) }
@@ -77,7 +77,7 @@ RSpec.describe Onboarding::Status, feature_category: :onboarding do
end
describe '#invite_with_tasks_to_be_done?' do
- subject { described_class.new(user).invite_with_tasks_to_be_done? }
+ subject { described_class.new(nil, nil, user).invite_with_tasks_to_be_done? }
context 'when there are tasks_to_be_done with one member' do
let_it_be(:member) { create(:group_member, user: user, tasks_to_be_done: tasks_to_be_done) }
diff --git a/spec/tasks/gitlab/audit_event_types/audit_event_types_rake_spec.rb b/spec/tasks/gitlab/audit_event_types/audit_event_types_rake_spec.rb
new file mode 100644
index 00000000000..14196ce4c5d
--- /dev/null
+++ b/spec/tasks/gitlab/audit_event_types/audit_event_types_rake_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require 'rake_helper'
+require_relative '../../../../lib/tasks/gitlab/audit_event_types/check_docs_task'
+require_relative '../../../../lib/tasks/gitlab/audit_event_types/compile_docs_task'
+
+RSpec.describe 'gitlab:audit_event_types rake tasks', :silence_stdout, feature_category: :audit_events do
+ before do
+ Rake.application.rake_require('tasks/gitlab/audit_event_types/audit_event_types')
+ stub_env('VERBOSE' => 'true')
+ Gitlab::Audit::Type::Definition.clear_memoization(:definitions)
+ end
+
+ describe 'compile_docs' do
+ it 'invokes Gitlab::AuditEventTypes::CompileDocsTask with correct arguments' do
+ compile_docs_task = instance_double(Tasks::Gitlab::AuditEventTypes::CompileDocsTask)
+
+ expect(Tasks::Gitlab::AuditEventTypes::CompileDocsTask).to receive(:new).with(
+ Rails.root.join("doc/administration/audit_event_streaming"),
+ Rails.root.join("doc/administration/audit_event_streaming/audit_event_types.md"),
+ Rails.root.join("tooling/audit_events/docs/templates/audit_event_types.md.erb")).and_return(compile_docs_task)
+
+ expect(compile_docs_task).to receive(:run)
+
+ run_rake_task('gitlab:audit_event_types:compile_docs')
+ end
+ end
+
+ describe 'check_docs' do
+ it 'invokes Gitlab::AuditEventTypes::CheckDocsTask with correct arguments' do
+ check_docs_task = instance_double(Tasks::Gitlab::AuditEventTypes::CheckDocsTask)
+
+ expect(Tasks::Gitlab::AuditEventTypes::CheckDocsTask).to receive(:new).with(
+ Rails.root.join("doc/administration/audit_event_streaming"),
+ Rails.root.join("doc/administration/audit_event_streaming/audit_event_types.md"),
+ Rails.root.join("tooling/audit_events/docs/templates/audit_event_types.md.erb")).and_return(check_docs_task)
+
+ expect(check_docs_task).to receive(:run)
+
+ run_rake_task('gitlab:audit_event_types:check_docs')
+ end
+ end
+end
diff --git a/spec/tasks/gitlab/audit_event_types/check_docs_task_spec.rb b/spec/tasks/gitlab/audit_event_types/check_docs_task_spec.rb
new file mode 100644
index 00000000000..5dd7599696b
--- /dev/null
+++ b/spec/tasks/gitlab/audit_event_types/check_docs_task_spec.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_relative '../../../../lib/tasks/gitlab/audit_event_types/check_docs_task'
+require_relative '../../../../lib/tasks/gitlab/audit_event_types/compile_docs_task'
+
+RSpec.describe Tasks::Gitlab::AuditEventTypes::CheckDocsTask, feature_category: :audit_events do
+ let_it_be(:docs_dir) { Rails.root.join("tmp/tests/doc/administration/audit_event_streaming") }
+ let_it_be(:docs_path) { Rails.root.join(docs_dir, 'audit_event_types.md') }
+ let_it_be(:template_erb_path) { Rails.root.join("tooling/audit_events/docs/templates/audit_event_types.md.erb") }
+
+ subject(:check_docs_task) { described_class.new(docs_dir, docs_path, template_erb_path) }
+
+ describe '#run' do
+ before do
+ Gitlab::Audit::Type::Definition.clear_memoization(:definitions)
+ Tasks::Gitlab::AuditEventTypes::CompileDocsTask.new(docs_dir, docs_path, template_erb_path).run
+ end
+
+ context 'when audit_event_types.md is up to date' do
+ it 'outputs success message after checking the documentation' do
+ expect { subject.run }.to output("Audit event types documentation is up to date.\n").to_stdout
+ end
+ end
+
+ context 'when audit_event_types.md is updated manually' do
+ before do
+ File.write(docs_path, "Manually adding this line at the end of the audit_event_types.md", mode: 'a+')
+ end
+
+ it 'raises an error' do
+ expected_output = "Audit event types documentation is outdated! Please update it " \
+ "by running `bundle exec rake gitlab:audit_event_types:compile_docs`"
+
+ expect { subject.run }.to raise_error(SystemExit).and output(/#{expected_output}/).to_stdout
+ end
+ end
+
+ context 'when an existing audit event type is removed' do
+ let_it_be(:updated_definition) { Gitlab::Audit::Type::Definition.definitions.except(:feature_flag_created) }
+
+ it 'raises an error' do
+ expect(Gitlab::Audit::Type::Definition).to receive(:definitions).and_return(updated_definition)
+
+ expected_output = "Audit event types documentation is outdated! Please update it " \
+ "by running `bundle exec rake gitlab:audit_event_types:compile_docs`"
+
+ expect { subject.run }.to raise_error(SystemExit).and output(/#{expected_output}/).to_stdout
+ end
+ end
+
+ context 'when an existing audit event type is updated' do
+ let_it_be(:updated_definition) { Gitlab::Audit::Type::Definition.definitions }
+
+ it 'raises an error' do
+ updated_definition[:feature_flag_created].attributes[:streamed] = false
+
+ expect(Gitlab::Audit::Type::Definition).to receive(:definitions).and_return(updated_definition)
+
+ expected_output = "Audit event types documentation is outdated! Please update it " \
+ "by running `bundle exec rake gitlab:audit_event_types:compile_docs`"
+
+ expect { subject.run }.to raise_error(SystemExit).and output(/#{expected_output}/).to_stdout
+ end
+ end
+ end
+end
diff --git a/spec/tasks/gitlab/audit_event_types/compile_docs_task_spec.rb b/spec/tasks/gitlab/audit_event_types/compile_docs_task_spec.rb
new file mode 100644
index 00000000000..a881d17d3b8
--- /dev/null
+++ b/spec/tasks/gitlab/audit_event_types/compile_docs_task_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_relative '../../../../lib/tasks/gitlab/audit_event_types/compile_docs_task'
+
+RSpec.describe Tasks::Gitlab::AuditEventTypes::CompileDocsTask, feature_category: :audit_events do
+ let_it_be(:docs_dir) { Rails.root.join("tmp/tests/doc/administration/audit_event_streaming") }
+ let_it_be(:docs_path) { Rails.root.join(docs_dir, 'audit_event_types.md') }
+ let_it_be(:template_erb_path) { Rails.root.join("tooling/audit_events/docs/templates/audit_event_types.md.erb") }
+
+ subject(:compile_docs_task) { described_class.new(docs_dir, docs_path, template_erb_path) }
+
+ describe '#run' do
+ it 'outputs message after compiling the documentation' do
+ expect { subject.run }.to output("Documentation compiled.\n").to_stdout
+ end
+
+ it 'creates audit_event_types.md', :aggregate_failures do
+ FileUtils.rm_f(docs_path)
+
+ expect { File.read(docs_path) }.to raise_error(Errno::ENOENT)
+
+ subject.run
+
+ expect(File.read(docs_path).size).not_to eq(0)
+ expect(File.read(docs_path)).to match(/This documentation is auto generated by a Rake task/)
+ end
+ end
+end
diff --git a/spec/views/registrations/welcome/show.html.haml_spec.rb b/spec/views/registrations/welcome/show.html.haml_spec.rb
index 866f4f62493..4188bd7e956 100644
--- a/spec/views/registrations/welcome/show.html.haml_spec.rb
+++ b/spec/views/registrations/welcome/show.html.haml_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe 'registrations/welcome/show', feature_category: :onboarding do
let_it_be(:user) { create(:user) }
before do
+ allow(view).to receive(:onboarding_status).and_return(Onboarding::Status.new({}, {}, user))
allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:welcome_update_params).and_return({})