Commit 34fd92dc authored by Vasilii Iakliushin's avatar Vasilii Iakliushin Committed by James Lopez

Add an endpoint for Static Editor Editor

* Add controller, view and route
* Add a simple controller test

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/212558
parent e46df320
# frozen_string_literal: true
class Projects::StaticSiteEditorController < Projects::ApplicationController
layout 'fullscreen'
prepend_before_action :authenticate_user!, only: [:show]
def show
end
end
......@@ -67,6 +67,10 @@ scope format: false do
end
end
scope controller: :static_site_editor do
get '/sse/*id', action: :show, as: :show_sse
end
get '/tree/*id', to: 'tree#show', as: :tree
get '/raw/*id', to: 'raw#show', as: :raw
get '/blame/*id', to: 'blame#show', as: :blame
......
......@@ -98,6 +98,7 @@ module Gitlab
preview
raw
refs
sse
tree
update
wikis
......
# frozen_string_literal: true
require 'spec_helper'
describe Projects::StaticSiteEditorController do
let(:project) { create(:project, :public, :repository) }
describe 'GET show' do
let(:default_params) do
{
namespace_id: project.namespace,
project_id: project,
id: 'master/README.md'
}
end
context 'User roles' do
context 'anonymous' do
before do
get :show, params: default_params
end
it 'redirects to sign in and returns' do
expect(response).to redirect_to(new_user_session_path)
end
end
%w[guest developer maintainer].each do |role|
context "as #{role}" do
let(:user) { create(:user) }
before do
project.add_role(user, role)
sign_in(user)
get :show, params: default_params
end
it 'renders the edit page' do
expect(response).to render_template(:show)
end
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