Add tests

pull/1229/head
Rick Carlino 2019-06-10 15:15:10 -05:00
parent d67d3b2935
commit 701b416ced
2 changed files with 20 additions and 12 deletions

View File

@ -10,11 +10,10 @@ describe Api::FarmwareInstallationsController do
url = Faker::Internet.url + "/manifest.json"
payload = { url: url }
old_installation_count = FarmwareInstallation.count
post :create, body: payload.to_json, params: {format: :json}
post :create, body: payload.to_json, params: { format: :json }
expect(response.status).to eq(200)
expect(FarmwareInstallation.count).to be > old_installation_count
expect(json.keys.sort)
.to eq([:created_at, :id, :package, :package_error, :updated_at, :url])
expect(json.keys.sort).to eq([:created_at, :id, :package, :package_error, :updated_at, :url])
expect(json[:url]).to eq(url)
expect(FarmwareInstallation.find(json[:id]).device).to eq(user.device)
end
@ -24,7 +23,7 @@ describe Api::FarmwareInstallationsController do
url = "This is not a valid URL."
payload = { url: url }
old_installation_count = FarmwareInstallation.count
post :create, body: payload.to_json, params: {format: :json}
post :create, body: payload.to_json, params: { format: :json }
expect(response.status).to eq(422)
expect(FarmwareInstallation.count).to eq(old_installation_count)
expect(json[:error]).to eq("Validation failed: Url is an invalid URL")
@ -66,7 +65,7 @@ describe Api::FarmwareInstallationsController do
sign_in user
installation = FactoryBot.create(:farmware_installation, device: user.device)
old_installation_count = FarmwareInstallation.count
delete :destroy, params: {id: installation.id}
delete :destroy, params: { id: installation.id }
expect(response.status).to eq(200)
expect(FarmwareInstallation.count).to be < old_installation_count
end

View File

@ -7,13 +7,22 @@ describe Api::PointsController do
let(:user) { FactoryBot.create(:user) }
let(:device) { user.device }
it 'renders a tool slot' do
tool_slot = ToolSlot.create!(x: 0,
y: 0,
z: 0,
radius: 0,
device: user.device,
pointer_type: "ToolSlot")
it "renders archived points" do
point = FactoryBot.create(:generic_pointer, device: device)
point.discard
sign_in user
get :show, params: { id: point.id }
expect(response.status).to eq(200)
expect(json.fetch(:id)).to eq(point.id)
end
it "renders a tool slot" do
tool_slot = ToolSlot.create!(x: 0,
y: 0,
z: 0,
radius: 0,
device: user.device,
pointer_type: "ToolSlot")
sign_in user
payload = { id: tool_slot.id }
get :show, params: payload