kaiho/test/controllers/softwares_controller_test.rb

57 lines
1.4 KiB
Ruby
Raw Normal View History

2018-07-22 15:44:29 +00:00
require 'test_helper'
class SoftwaresControllerTest < ActionDispatch::IntegrationTest
test 'should not save software without name' do
software = Software.new
assert_not software.save
end
test 'save software without website' do
data = { name: 'MySoft' }
software = Software.new(data)
assert software.save
assert_equal data[:name], software.name
end
test 'save software with website' do
data = { name: 'MySoft', website: 'https://mysoft.local' }
software = Software.new(data)
assert software.save
assert_equal data[:name], software.name
end
test 'should not save software with same name' do
data = { name: 'Ruby on Rails' }
software = Software.new(data)
assert_not software.save
end
test 'should get index' do
get softwares_url
assert_response :success
assert_select 'title', 'Kaiho'
assert_select 'h3', 'Softwares'
assert_select 'td', 'Ruby on Rails'
assert_select 'td', 'https://rubyonrails.org'
assert_select 'td', 'Kaiho'
assert_select 'td', 'https://kaiho.local'
end
test 'should get show software' do
software = Software.find_by_name('Ruby on Rails')
get software_path(software)
assert_response :success
assert_select 'title', 'Kaiho'
assert_select 'h3', 'Ruby on Rails'
2018-07-22 19:45:53 +00:00
assert_select 'td', '1.0.0'
assert_select 'td', '2018-07-22'
assert_select 'td', '1.1.0'
assert_select 'td', '2018-12-22'
2018-07-22 15:44:29 +00:00
end
end