kaiho/test/controllers/github_repository_controller_test.rb

63 lines
1.5 KiB
Ruby

require 'test_helper'
class GithubRepositoryControllerTest < ActionDispatch::IntegrationTest
test 'should not save repository without data' do
repository = GithubRepository.new
assert_not repository.save
end
test 'should not save repository without software_id' do
data = { name: 'test/test' }
repository = GithubRepository.new(data)
assert_not repository.save
end
test 'should not save repository if a repository already exist' do
data = {
name: 'test/test',
software_id: Software.find_by_name('Ruby on Rails').id
}
repository = GithubRepository.new(data)
assert_not repository.save
end
test 'should not save repository if a repository has the same name' do
data = {
name: 'rails/rails',
software_id: Software.find_by_name('Kaiho').id
}
repository = GithubRepository.new(data)
assert_not repository.save
end
test 'should save repository' do
data = {
name: 'kaiho/kaiho',
software_id: Software.find_by_name('Kaiho').id
}
repository = GithubRepository.new(data)
assert repository.save
end
test 'should not update repository if a repository has the same name' do
data = {
name: 'rails/rails'
}
repository = GithubRepository.find_by_name('ruby/ruby')
assert_not repository.update(data)
end
test 'should update repository' do
data = {
name: 'rails/rails2'
}
repository = GithubRepository.find_by_name('rails/rails')
assert repository.update(data)
end
end