-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add revenue attribute to prediction, trip, and vehicle views
- Loading branch information
Showing
6 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
defmodule ApiWeb.VehicleViewTest do | ||
use ApiWeb.ConnCase | ||
|
||
# Bring render/3 and render_to_string/3 for testing custom views | ||
import Phoenix.View | ||
|
||
alias Model.Vehicle | ||
|
||
@vehicle %Vehicle{ | ||
id: "vehicle", | ||
revenue: :REVENUE | ||
} | ||
|
||
setup %{conn: conn} do | ||
conn = Phoenix.Controller.put_view(conn, ApiWeb.VehicleView) | ||
{:ok, %{conn: conn}} | ||
end | ||
|
||
test "render returns JSONAPI", %{conn: conn} do | ||
rendered = render(ApiWeb.VehicleView, "index.json-api", data: @vehicle, conn: conn) | ||
assert rendered["data"]["type"] == "vehicle" | ||
assert rendered["data"]["id"] == "vehicle" | ||
|
||
assert rendered["data"]["attributes"] == %{ | ||
"direction_id" => nil, | ||
"revenue" => "REVENUE", | ||
"bearing" => nil, | ||
"carriages" => [], | ||
"current_status" => nil, | ||
"current_stop_sequence" => nil, | ||
"label" => nil, | ||
"latitude" => nil, | ||
"longitude" => nil, | ||
"occupancy_status" => nil, | ||
"speed" => nil, | ||
"updated_at" => nil | ||
} | ||
end | ||
end |