2019-07-16 19:47:44 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-09-29 21:22:28 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
2019-07-16 19:47:44 +00:00
|
|
|
class RepositoryTest < ActiveSupport::TestCase
|
|
|
|
setup do
|
|
|
|
@rol = create :rol
|
|
|
|
@site = @rol.site
|
|
|
|
@usuarie = @rol.usuarie
|
|
|
|
|
|
|
|
# Volver al principio para poder traer cambios
|
|
|
|
Dir.chdir(@site.path) do
|
|
|
|
`git reset --hard e0627e34c6ef6ae2592d7f289b82def20ba56685`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
teardown do
|
|
|
|
@site.destroy
|
|
|
|
end
|
|
|
|
|
2021-04-16 13:27:37 +00:00
|
|
|
test 'se puede obtener la rama por defecto' do
|
|
|
|
assert_equal 'master', @site.repository.default_branch
|
|
|
|
|
|
|
|
random_branch = SecureRandom.hex
|
|
|
|
|
|
|
|
Dir.chdir(@site.path) do
|
|
|
|
`git checkout -b #{random_branch} >/dev/null 2>&1`
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal random_branch, @site.repository.default_branch
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'los nombres de las ramas pueden tener /' do
|
|
|
|
random_branch = ([SecureRandom.hex] * 2).join('/')
|
|
|
|
|
|
|
|
Dir.chdir(@site.path) do
|
|
|
|
`git checkout -b #{random_branch} >/dev/null 2>&1`
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal random_branch, @site.repository.default_branch
|
|
|
|
end
|
|
|
|
|
2019-07-16 19:47:44 +00:00
|
|
|
test 'se pueden traer cambios' do
|
|
|
|
assert @site.repository.fetch.is_a?(Integer)
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'se pueden mergear los cambios' do
|
|
|
|
assert !@site.repository.commits.empty?
|
|
|
|
assert @site.repository.merge(@usuarie)
|
|
|
|
assert @site.repository.commits.empty?
|
|
|
|
|
|
|
|
assert_equal @usuarie.name,
|
2021-04-16 13:27:37 +00:00
|
|
|
@site.repository.rugged.branches[@site.repository.default_branch].target.author[:name]
|
2019-07-16 19:47:44 +00:00
|
|
|
|
|
|
|
Dir.chdir(@site.path) do
|
2021-02-23 22:00:38 +00:00
|
|
|
FileUtils.rm 'migration.csv'
|
2020-09-29 21:22:28 +00:00
|
|
|
|
2019-07-16 19:47:44 +00:00
|
|
|
assert_equal 'nothing to commit, working tree clean',
|
|
|
|
`LC_ALL=C git status`.strip.split("\n").last
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|