feat: add github repository

This commit is contained in:
Adrien Waksberg 2018-07-29 21:06:32 +02:00
parent 5154b4b632
commit 97b9a87d26
16 changed files with 172 additions and 3 deletions

View file

@ -0,0 +1,45 @@
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 with the same name exist' 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
end

5
test/fixtures/github_repositories.yml vendored Normal file
View file

@ -0,0 +1,5 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: rails/rails
software: two

View file

@ -0,0 +1,7 @@
require 'test_helper'
class GithubRepositoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -0,0 +1,7 @@
require 'test_helper'
class RepositoryGithubTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end