Commit f850b1bd authored by Stan Hu's avatar Stan Hu

Merge branch 'ce-to-ee-2018-05-11' into 'master'

CE upstream - 2018-05-11 18:29 UTC

See merge request gitlab-org/gitlab-ee!5681
parents 85681f7f f556ce24
...@@ -13,8 +13,7 @@ class ApplicationController < ActionController::Base ...@@ -13,8 +13,7 @@ class ApplicationController < ActionController::Base
before_action :authenticate_sessionless_user! before_action :authenticate_sessionless_user!
before_action :authenticate_user! before_action :authenticate_user!
before_action :enforce_terms!, if: -> { Gitlab::CurrentSettings.current_application_settings.enforce_terms }, before_action :enforce_terms!, if: :should_enforce_terms?
unless: :peek_request?
before_action :validate_user_service_ticket! before_action :validate_user_service_ticket!
before_action :check_password_expiration before_action :check_password_expiration
before_action :ldap_security_check before_action :ldap_security_check
...@@ -381,4 +380,10 @@ class ApplicationController < ActionController::Base ...@@ -381,4 +380,10 @@ class ApplicationController < ActionController::Base
def peek_request? def peek_request?
request.path.start_with?('/-/peek') request.path.start_with?('/-/peek')
end end
def should_enforce_terms?
return false unless Gitlab::CurrentSettings.current_application_settings.enforce_terms
!(peek_request? || devise_controller?)
end
end end
...@@ -490,43 +490,43 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -490,43 +490,43 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
id: job.id id: job.id
end end
context 'when job has a trace artifact' do context "when job has a trace artifact" do
let(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) } let(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
it 'returns a trace' do it 'returns a trace' do
response = subject response = subject
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'text/plain; charset=utf-8' expect(response.headers["Content-Type"]).to eq("text/plain; charset=utf-8")
expect(response.body).to eq job.job_artifacts_trace.open.read expect(response.body).to eq(job.job_artifacts_trace.open.read)
end end
end end
context 'when job has a trace file' do context "when job has a trace file" do
let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) } let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) }
it 'send a trace file' do it "send a trace file" do
response = subject response = subject
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'text/plain; charset=utf-8' expect(response.headers["Content-Type"]).to eq("text/plain; charset=utf-8")
expect(response.body).to eq 'BUILD TRACE' expect(response.body).to eq("BUILD TRACE")
end end
end end
context 'when job has a trace in database' do context "when job has a trace in database" do
let(:job) { create(:ci_build, pipeline: pipeline) } let(:job) { create(:ci_build, pipeline: pipeline) }
before do before do
job.update_column(:trace, 'Sample trace') job.update_column(:trace, "Sample trace")
end end
it 'send a trace file' do it "send a trace file" do
response = subject response = subject
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'text/plain; charset=utf-8' expect(response.headers["Content-Type"]).to eq("text/plain; charset=utf-8")
expect(response.body).to eq 'Sample trace' expect(response.body).to eq("Sample trace")
end end
end end
......
...@@ -81,4 +81,22 @@ describe 'Users > Terms' do ...@@ -81,4 +81,22 @@ describe 'Users > Terms' do
expect(find_field('issue_description').value).to eq("We don't want to lose what the user typed") expect(find_field('issue_description').value).to eq("We don't want to lose what the user typed")
end end
end end
context 'when the terms are enforced' do
before do
enforce_terms
end
context 'signing out', :js do
it 'allows the user to sign out without a response' do
visit terms_path
find('.header-user-dropdown-toggle').click
click_link('Sign out')
expect(page).to have_content('Sign in')
expect(page).to have_content('Register')
end
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