debian-mirror-gitlab/spec/controllers/import/gitea_controller_spec.rb

70 lines
1.6 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe Import::GiteaController do
include ImportSpecHelper
let(:provider) { :gitea }
let(:host_url) { 'https://try.gitea.io' }
include_context 'a GitHub-ish import controller'
def assign_host_url
session[:gitea_host_url] = host_url
end
describe "GET new" do
it_behaves_like 'a GitHub-ish import controller: GET new' do
before do
assign_host_url
end
end
end
describe "POST personal_access_token" do
it_behaves_like 'a GitHub-ish import controller: POST personal_access_token'
end
describe "GET status" do
it_behaves_like 'a GitHub-ish import controller: GET status' do
2020-04-08 14:13:33 +05:30
let(:extra_assign_expectations) { { gitea_host_url: host_url } }
2017-08-17 22:00:37 +05:30
before do
assign_host_url
end
2020-04-08 14:13:33 +05:30
context 'when host url is local or not http' do
%w[https://localhost:3000 http://192.168.0.1 ftp://testing].each do |url|
let(:host_url) { url }
it 'denies network request' do
get :status, format: :json
expect(controller).to redirect_to(new_import_url)
2020-04-22 19:07:51 +05:30
expect(flash[:alert]).to eq('Specified URL cannot be used: "Only allowed schemes are http, https"')
2020-04-08 14:13:33 +05:30
end
end
end
2017-08-17 22:00:37 +05:30
end
end
describe 'POST create' do
it_behaves_like 'a GitHub-ish import controller: POST create' do
before do
assign_host_url
end
end
2020-03-13 15:44:24 +05:30
it_behaves_like 'project import rate limiter'
2017-08-17 22:00:37 +05:30
end
2019-07-07 11:18:12 +05:30
describe "GET realtime_changes" do
it_behaves_like 'a GitHub-ish import controller: GET realtime_changes' do
before do
assign_host_url
end
end
end
2017-08-17 22:00:37 +05:30
end