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,25 +2,27 @@ ...@@ -2,25 +2,27 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Projects::BranchesController, '(JavaScript fixtures)', type: :controller do RSpec.describe 'Branches (JavaScript fixtures)' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) } let_it_be(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let_it_be(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') } let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
render_views
before(:all) do before(:all) do
clean_frontend_fixtures('branches/') clean_frontend_fixtures('branches/')
clean_frontend_fixtures('api/branches/')
end end
before do after(:all) do
sign_in(admin) remove_repository(project)
end end
after do describe Projects::BranchesController, '(JavaScript fixtures)', type: :controller do
remove_repository(project) render_views
before do
sign_in(admin)
end end
it 'branches/new_branch.html' do it 'branches/new_branch.html' do
...@@ -31,4 +33,20 @@ RSpec.describe Projects::BranchesController, '(JavaScript fixtures)', type: :con ...@@ -31,4 +33,20 @@ RSpec.describe Projects::BranchesController, '(JavaScript fixtures)', type: :con
expect(response).to be_successful expect(response).to be_successful
end end
end
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
end
end
end end
...@@ -2,25 +2,35 @@ ...@@ -2,25 +2,35 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Projects::CommitController, '(JavaScript fixtures)', type: :controller do RSpec.describe 'Commit (JavaScript fixtures)' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:commit) { project.commit("master") } let_it_be(:commit) { project.commit("master") }
render_views
before(:all) do before(:all) do
clean_frontend_fixtures('commit/') clean_frontend_fixtures('commit/')
clean_frontend_fixtures('api/commits/')
project.add_maintainer(user)
end end
before do before do
project.add_maintainer(user)
sign_in(user)
allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon') allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
end end
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 it 'commit/show.html' do
params = { params = {
namespace_id: project.namespace, namespace_id: project.namespace,
...@@ -32,4 +42,15 @@ RSpec.describe Projects::CommitController, '(JavaScript fixtures)', type: :contr ...@@ -32,4 +42,15 @@ RSpec.describe Projects::CommitController, '(JavaScript fixtures)', type: :contr
expect(response).to be_successful expect(response).to be_successful
end end
end
describe API::Commits, '(JavaScript fixtures)', type: :request do
include ApiHelpers
it 'api/commits/commit.json' do
get api("/projects/#{project.id}/repository/commits/#{commit.id}", user)
expect(response).to be_successful
end
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