Skip to content

Commit

Permalink
The Content-Type header should be more accurate.
Browse files Browse the repository at this point in the history
We're not sending back HTML, we're sending back specific codes for
a specific printer. The content type should therefore indicate that,
and match the type in the `HTTP_ACCEPT` header.

Closes #42
  • Loading branch information
lazyatom committed Feb 27, 2013
1 parent 44421e7 commit 8e15d93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/printer/backend_server/polling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Printer::BackendServer::Polling < Printer::BackendServer::Base
printer = Printer::RemotePrinter.find(params["printer_id"])
printer.update(remote_printer_params(params))
Printer::PrinterIPLookup.update(printer, request.ip)
headers "Content-Type" => env["HTTP_ACCEPT"]
printer.data_to_print
end

Expand Down
8 changes: 8 additions & 0 deletions test/backend_server/polling_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def app
get "/printer/1"
last_response.body.must_equal "data"
end

it "responds with a content type that matches the printer type" do
printer = Printer::RemotePrinter.new("1")
Printer::RemotePrinter.stubs(:find).with("1").returns(printer)
printer.stubs(:data_to_print).returns("data")
get "/printer/1", {}, {"HTTP_ACCEPT" => "application/vnd.freerange.printer.printer-type"}
last_response.headers["Content-Type"].must_equal "application/vnd.freerange.printer.printer-type"
end
end

describe "updating printer information" do
Expand Down

0 comments on commit 8e15d93

Please sign in to comment.