Commit 3629dc33 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Display terms to a user

When terms are present, they can be viewed on `/-/users/terms`.
parent 17b25bd2
......@@ -61,3 +61,4 @@
@import 'framework/stacked_progress_bar';
@import 'framework/ci_variable_list';
@import 'framework/feature_highlight';
@import 'framework/terms';
.terms {
.panel {
.panel-heading {
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: space-between;
.title {
display: -webkit-flex;
display: flex;
align-items: center;
padding: 2px 8px;
margin: 5px 2px 5px -8px;
border-radius: 4px;
.logo-text {
width: 55px;
height: 24px;
margin: 0 15px;
}
}
.navbar-collapse {
padding-right: 0;
}
.nav li a {
color: $theme-gray-700;
}
}
.panel-content {
padding: 0 $gl-padding;
}
}
}
module Users
class TermsController < ApplicationController
before_action :terms
layout 'terms'
def index
end
private
def terms
unless @terms = Gitlab::CurrentSettings.current_application_settings.latest_terms
redirect_to request.referer || root_path
end
end
end
end
!!! 5
- @hide_breadcrumbs = true
%html{ lang: I18n.locale, class: page_class }
= render "layouts/head"
%body{ class: "#{user_application_theme} #{@body_class}", data: { page: body_data_page } }
= render 'peek/bar'
.layout-page.terms
.content-wrapper
%div{ class: "#{(container_class unless @no_container)} #{@content_class}" }
.content{ id: "content-body" }
.panel.panel-default
.panel-heading
.title
= brand_header_logo
- logo_text = brand_header_logo_type
- if logo_text.present?
%span.logo-text.hidden-xs
= logo_text
- if header_link?(:user_dropdown)
.navbar-collapse.collapse
%ul.nav.navbar-nav
%li.header-user.dropdown
= link_to current_user, class: user_dropdown_class, data: { toggle: "dropdown" } do
= image_tag avatar_icon_for_user(current_user, 23), width: 23, height: 23, class: "header-user-avatar qa-user-avatar"
= sprite_icon('angle-down', css_class: 'caret-down')
.dropdown-menu-nav.dropdown-menu-align-right
= render 'layouts/header/current_user_dropdown'
= yield
= yield :scripts_body
.panel-content.rendered-terms
= markdown_field(@terms, :terms)
......@@ -27,6 +27,13 @@ devise_scope :user do
get '/users/almost_there' => 'confirmations#almost_there'
end
scope '-/users', module: :users do
resources :terms, only: [:index] do
post :accept, on: :member
post :decline, on: :member
end
end
scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) do
scope(path: 'users/:username',
as: :user,
......
require 'spec_helper'
describe Users::TermsController do
let(:user) { create(:user) }
before do
sign_in user
end
describe 'GET #index' do
it 'redirects when no terms exist' do
get :index
expect(response).to have_gitlab_http_status(:redirect)
end
it 'shows terms when they exist' do
create(:term)
expect(response).to have_gitlab_http_status(:success)
end
end
end
require 'spec_helper'
describe 'Users > Terms' do
let(:user) { create(:user) }
let!(:term) { create(:term, terms: 'By accepting, you promise to be nice!') }
before do
sign_in(user)
visit terms_path
end
it 'shows the terms' do
expect(page).to have_content('By accepting, you promise to be nice!')
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