@@ -6,12 +6,14 @@ defmodule Phoenix.Sync.RouterTest do
66 parameterize: [
77 % {
88 sync_config: [
9+ env: :test ,
910 mode: :embedded ,
1011 pool_opts: @ pool_opts
1112 ]
1213 } ,
1314 % {
1415 sync_config: [
16+ env: :test ,
1517 mode: :http ,
1618 url: "http://localhost:3000" ,
1719 pool_opts: @ pool_opts
@@ -135,6 +137,29 @@ defmodule Phoenix.Sync.RouterTest do
135137 ] = Jason . decode! ( resp . resp_body )
136138 end
137139
140+ @ tag table: {
141+ "todos" ,
142+ [
143+ "id int8 not null primary key generated always as identity" ,
144+ "title text" ,
145+ "completed boolean default false"
146+ ]
147+ }
148+ @ tag data: { "todos" , [ "title" ] , [ [ "one" ] , [ "two" ] , [ "three" ] ] }
149+
150+ test "returns a correct content-type header" , _ctx do
151+ resp =
152+ Phoenix.ConnTest . build_conn ( )
153+ |> Phoenix.ConnTest . get ( "/sync/things-to-do" , % { offset: "-1" } )
154+
155+ assert resp . status == 200
156+ assert Plug.Conn . get_resp_header ( resp , "electric-offset" ) == [ "0_0" ]
157+
158+ assert Plug.Conn . get_resp_header ( resp , "content-type" ) == [
159+ "application/json; charset=utf-8"
160+ ]
161+ end
162+
138163 @ tag table: {
139164 "ideas" ,
140165 [
@@ -362,9 +387,7 @@ defmodule Phoenix.Sync.RouterTest do
362387 end
363388
364389 setup ( ctx ) do
365- opts = Phoenix.Sync . plug_opts ( electric_opts ( ctx ) )
366-
367- [ plug_opts: [ phoenix_sync: opts ] ]
390+ [ plug_opts: [ phoenix_sync: Phoenix.Sync . plug_opts ( ctx . electric_opts ) ] ]
368391 end
369392
370393 test "raises compile-time error if Plug.Router is not configured to copy_opts_to_assign" do
0 commit comments