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>2020-01-20 18:09:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-20 18:09:18 +0300
commit364f6f2e33e6f5eafe63b25d9256b88e72141b1c (patch)
treeee6dc003a354e7466d5c45e5587c0f8172312122 /spec
parent98252e0dd60cbcb316231085e206d9872f243b8a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/initializers/action_mailer_hooks_spec.rb5
-rw-r--r--spec/lib/gitlab/request_context_spec.rb18
-rw-r--r--spec/policies/project_policy_spec.rb28
-rw-r--r--spec/requests/api/events_spec.rb12
4 files changed, 60 insertions, 3 deletions
diff --git a/spec/initializers/action_mailer_hooks_spec.rb b/spec/initializers/action_mailer_hooks_spec.rb
index ce6e1ed0fa2..20f96f7e16c 100644
--- a/spec/initializers/action_mailer_hooks_spec.rb
+++ b/spec/initializers/action_mailer_hooks_spec.rb
@@ -35,8 +35,11 @@ describe 'ActionMailer hooks' do
load Rails.root.join('config/initializers/action_mailer_hooks.rb')
if smime_interceptor_enabled
+ # Premailer must be registered before S/MIME or signatures will be mangled
expect(ActionMailer::Base).to(
- have_received(:register_interceptor).with(Gitlab::Email::Hook::SmimeSignatureInterceptor))
+ have_received(:register_interceptor).with(::Premailer::Rails::Hook).ordered)
+ expect(ActionMailer::Base).to(
+ have_received(:register_interceptor).with(Gitlab::Email::Hook::SmimeSignatureInterceptor).ordered)
else
expect(ActionMailer::Base).not_to(
have_received(:register_interceptor).with(Gitlab::Email::Hook::SmimeSignatureInterceptor))
diff --git a/spec/lib/gitlab/request_context_spec.rb b/spec/lib/gitlab/request_context_spec.rb
index 1290071549d..5785dbfd850 100644
--- a/spec/lib/gitlab/request_context_spec.rb
+++ b/spec/lib/gitlab/request_context_spec.rb
@@ -10,10 +10,12 @@ describe Gitlab::RequestContext, :request_store do
describe '#request_deadline' do
let(:request_start_time) { 1575982156.206008 }
- it "sets the time to #{Settings.gitlab.max_request_duration_seconds} seconds in the future" do
+ before do
allow(subject).to receive(:request_start_time).and_return(request_start_time)
+ end
- expect(subject.request_deadline).to eq(1575982156.206008 + Settings.gitlab.max_request_duration_seconds)
+ it "sets the time to #{Settings.gitlab.max_request_duration_seconds} seconds in the future" do
+ expect(subject.request_deadline).to eq(request_start_time + Settings.gitlab.max_request_duration_seconds)
expect(subject.request_deadline).to be_a(Float)
end
@@ -22,6 +24,18 @@ describe Gitlab::RequestContext, :request_store do
expect(subject.request_deadline).to be_nil
end
+
+ it 'only checks the feature once per request-instance' do
+ expect(Feature).to receive(:enabled?).with(:request_deadline).once
+
+ 2.times { subject.request_deadline }
+ end
+
+ it 'returns nil when the feature is disabled' do
+ stub_feature_flags(request_deadline: false)
+
+ expect(subject.request_deadline).to be_nil
+ end
end
describe '#ensure_request_deadline_not_exceeded!' do
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index 188eafadfc1..e47204c774b 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -508,6 +508,34 @@ describe ProjectPolicy do
end
end
+ context 'forking a project' do
+ subject { described_class.new(current_user, project) }
+
+ context 'anonymous user' do
+ let(:current_user) { nil }
+
+ it { is_expected.to be_disallowed(:fork_project) }
+ end
+
+ context 'project member' do
+ let_it_be(:project) { create(:project, :private) }
+
+ context 'guest' do
+ let(:current_user) { guest }
+
+ it { is_expected.to be_disallowed(:fork_project) }
+ end
+
+ %w(reporter developer maintainer).each do |role|
+ context role do
+ let(:current_user) { send(role) }
+
+ it { is_expected.to be_allowed(:fork_project) }
+ end
+ end
+ end
+ end
+
describe 'update_max_artifacts_size' do
subject { described_class.new(current_user, project) }
diff --git a/spec/requests/api/events_spec.rb b/spec/requests/api/events_spec.rb
index 240f9a02877..30e6a1340a8 100644
--- a/spec/requests/api/events_spec.rb
+++ b/spec/requests/api/events_spec.rb
@@ -171,6 +171,18 @@ describe API::Events do
expect(json_response[0]['target_id']).to eq(closed_issue.id)
end
end
+
+ context 'when scope is passed' do
+ context 'when unauthenticated' do
+ it 'returns no user events' do
+ get api("/users/#{user.username}/events?scope=all")
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(0)
+ end
+ end
+ end
end
it 'returns a 404 error if not found' do