Add tests

pull/896/head
Rick Carlino 2018-06-25 13:07:47 -05:00
parent 9d1c040c1b
commit 4c4c28493a
1 changed files with 12 additions and 6 deletions

View File

@ -20,16 +20,22 @@ describe Api::LogsController do
it "creates one log (legacy format)" do
sign_in user
before_count = Log.count
post :create,
body: { meta: { x: 1, y: 2, z: 3, type: "info" },
channels: ["toast"],
message: "Hello, world!"
}.to_json,
params: {format: :json}
now = DateTime.now - 37.3.hours
created_at = now.utc.to_i
post :create, body: {
created_at: created_at,
meta: { x: 1,
y: 2,
z: 3,
type: "info" },
channels: ["toast"],
message: "Hello, world!" }.to_json,
params: { format: :json }
expect(response.status).to eq(200)
expect(Log.count).to be > before_count
expect(Log.last.message).to eq("Hello, world!")
expect(Log.last.device).to eq(user.device)
expect(Log.last.created_at.to_time.to_s).to eq(now.to_time.to_s)
end
it "creates one log" do