Commit 94b59880 authored by Nathan Friend's avatar Nathan Friend Committed by Nicolò Maria Mezzopera

Add branches, tags, and commit API fixtures

This commit adds new API fixtures for frontend tests.
parent 42603e9b
......@@ -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