Commit 3fc14674 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch 'nfriend-add-some-frontend-fixtures' into 'master'

Add frontend fixtures for branches, tags, and commit API calls

See merge request gitlab-org/gitlab!35990
parents 5650e96c 94b59880
......@@ -2,33 +2,51 @@
require 'spec_helper'
RSpec.describe Projects::BranchesController, '(JavaScript fixtures)', type: :controller do
RSpec.describe 'Branches (JavaScript fixtures)' do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
render_views
let_it_be(:admin) { create(:admin) }
let_it_be(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
before(:all) do
clean_frontend_fixtures('branches/')
clean_frontend_fixtures('api/branches/')
end
before do
sign_in(admin)
after(:all) do
remove_repository(project)
end
after do
remove_repository(project)
describe Projects::BranchesController, '(JavaScript fixtures)', type: :controller do
render_views
before do
sign_in(admin)
end
it 'branches/new_branch.html' do
get :new, params: {
namespace_id: project.namespace.to_param,
project_id: project
}
expect(response).to be_successful
end
end
it 'branches/new_branch.html' do
get :new, params: {
namespace_id: project.namespace.to_param,
project_id: project
}
describe API::Branches, '(JavaScript fixtures)', type: :request do
include ApiHelpers
it 'api/branches/branches.json' do
# The search query "ma" matches a few branch names in the test
# repository with a variety of different properties, including:
# - "master": default, protected
# - "markdown": non-default, protected
# - "many_files": non-default, not protected
get api("/projects/#{project.id}/repository/branches?search=ma", admin)
expect(response).to be_successful
expect(response).to be_successful
end
end
end
......@@ -2,34 +2,55 @@
require 'spec_helper'
RSpec.describe Projects::CommitController, '(JavaScript fixtures)', type: :controller do
RSpec.describe 'Commit (JavaScript fixtures)' do
include JavaScriptFixturesHelpers
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
let(:commit) { project.commit("master") }
render_views
let_it_be(:commit) { project.commit("master") }
before(:all) do
clean_frontend_fixtures('commit/')
clean_frontend_fixtures('api/commits/')
project.add_maintainer(user)
end
before do
project.add_maintainer(user)
sign_in(user)
allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
end
it 'commit/show.html' do
params = {
namespace_id: project.namespace,
project_id: project,
id: commit.id
}
after(:all) do
remove_repository(project)
end
describe Projects::CommitController, '(JavaScript fixtures)', type: :controller do
render_views
before do
sign_in(user)
end
it 'commit/show.html' do
params = {
namespace_id: project.namespace,
project_id: project,
id: commit.id
}
get :show, params: params
expect(response).to be_successful
end
end
describe API::Commits, '(JavaScript fixtures)', type: :request do
include ApiHelpers
get :show, params: params
it 'api/commits/commit.json' do
get api("/projects/#{project.id}/repository/commits/#{commit.id}", user)
expect(response).to be_successful
expect(response).to be_successful
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Tags (JavaScript fixtures)' do
include JavaScriptFixturesHelpers
let_it_be(:admin) { create(:admin) }
let_it_be(:project) { create(:project, :repository, path: 'tags-project') }
before(:all) do
clean_frontend_fixtures('api/tags/')
end
after(:all) do
remove_repository(project)
end
describe API::Tags, '(JavaScript fixtures)', type: :request do
include ApiHelpers
it 'api/tags/tags.json' do
get api("/projects/#{project.id}/repository/tags", admin)
expect(response).to be_successful
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