feat: add softwares controller
This commit is contained in:
parent
cac31ff12c
commit
72e8c908f4
17 changed files with 259 additions and 0 deletions
test/controllers
52
test/controllers/softwares_controller_test.rb
Normal file
52
test/controllers/softwares_controller_test.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
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'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue