Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Clean up micropub creation spec
Browse files Browse the repository at this point in the history
What I was trying to do with the regex is figure out if location header
pointed at the micropost. A regex isn't needed for that, just an `eq`
matcher.

Also, I found a bug in that the location header needed to point toward
the full url, not just the path which is something a regex wouldn't have
noticed!
  • Loading branch information
edwardloveall committed Jun 14, 2018
1 parent cf7eb44 commit 7a645b1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/micropubs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ class Api::MicropubsController < ApplicationController

def create
micropost = Micropost.create(body: params[:content])
head :created, location: micropost_path(micropost)
head :created, location: micropost_url(micropost)
end
end
3 changes: 1 addition & 2 deletions spec/requests/micropub_creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

expect(Micropost.count).to eq(micropost_count + 1)
expect(response).to have_http_status(:created)
path_matcher = %r(#{microposts_path}/\d+)
expect(response.headers["Location"]).to match(path_matcher)
expect(response.headers["Location"]).to eq(micropost_url(Micropost.last))
end
end
end

0 comments on commit 7a645b1

Please sign in to comment.