Added table jobs and devices
This commit is contained in:
38
test/controllers/devices_controller_test.rb
Normal file
38
test/controllers/devices_controller_test.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
require "test_helper"
|
||||
|
||||
class DevicesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@device = devices(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get devices_url, as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create device" do
|
||||
assert_difference('Device.count') do
|
||||
post devices_url, params: { device: { device_id: @device.device_id } }, as: :json
|
||||
end
|
||||
|
||||
assert_response 201
|
||||
end
|
||||
|
||||
test "should show device" do
|
||||
get device_url(@device), as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update device" do
|
||||
patch device_url(@device), params: { device: { device_id: @device.device_id } }, as: :json
|
||||
assert_response 200
|
||||
end
|
||||
|
||||
test "should destroy device" do
|
||||
assert_difference('Device.count', -1) do
|
||||
delete device_url(@device), as: :json
|
||||
end
|
||||
|
||||
assert_response 204
|
||||
end
|
||||
end
|
||||
38
test/controllers/jobs_controller_test.rb
Normal file
38
test/controllers/jobs_controller_test.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
require "test_helper"
|
||||
|
||||
class JobsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@job = jobs(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get jobs_url, as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create job" do
|
||||
assert_difference('Job.count') do
|
||||
post jobs_url, params: { job: { job_id: @job.job_id, params: @job.params, type: @job.type } }, as: :json
|
||||
end
|
||||
|
||||
assert_response 201
|
||||
end
|
||||
|
||||
test "should show job" do
|
||||
get job_url(@job), as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update job" do
|
||||
patch job_url(@job), params: { job: { job_id: @job.job_id, params: @job.params, type: @job.type } }, as: :json
|
||||
assert_response 200
|
||||
end
|
||||
|
||||
test "should destroy job" do
|
||||
assert_difference('Job.count', -1) do
|
||||
delete job_url(@job), as: :json
|
||||
end
|
||||
|
||||
assert_response 204
|
||||
end
|
||||
end
|
||||
7
test/fixtures/devices.yml
vendored
Normal file
7
test/fixtures/devices.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
device_id: MyString
|
||||
|
||||
two:
|
||||
device_id: MyString
|
||||
11
test/fixtures/jobs.yml
vendored
Normal file
11
test/fixtures/jobs.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
job_id:
|
||||
params:
|
||||
type:
|
||||
|
||||
two:
|
||||
job_id:
|
||||
params:
|
||||
type:
|
||||
7
test/models/device_test.rb
Normal file
7
test/models/device_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class DeviceTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/models/job_test.rb
Normal file
7
test/models/job_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class JobTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user