Add checkins

This commit is contained in:
2023-02-25 12:51:19 +11:00
parent 9b88818941
commit 9fe40896fa
8 changed files with 236 additions and 5 deletions

View File

@@ -42,4 +42,106 @@ RSpec.describe Adamantium::MicropubRequestParser do
end
end
end
context "checkin request" do
let(:params) {
json = '{
"type": [
"h-entry"
],
"properties": {
"published": [
"2023-02-25T10:24:30+11:00"
],
"syndication": [
"https://www.swarmapp.com/user/1390949/checkin/63f9472ed36fa977ac188903"
],
"content": [
"Coffee time!!"
],
"category": [
"check-in"
],
"checkin": [
{
"type": [
"h-card"
],
"properties": {
"name": [
"St Rose"
],
"url": [
"https://foursquare.com/v/527da837498e9d7fee64bb75",
"http://www.strose.com.au"
],
"tel": [
"(03) 9331 4488"
],
"latitude": [
-37.75627
],
"longitude": [
144.91555
],
"street-address": [
"19 Rose St"
],
"locality": [
"Essendon"
],
"region": [
"VIC"
],
"country-name": [
"Australia"
],
"postal-code": [
"3040"
]
},
"value": "https://foursquare.com/v/527da837498e9d7fee64bb75"
}
],
"location": [
{
"type": [
"h-adr"
],
"properties": {
"latitude": [
-37.75627
],
"longitude": [
144.91555
],
"street-address": [
"19 Rose St"
],
"locality": [
"Essendon"
],
"region": [
"VIC"
],
"country-name": [
"Australia"
],
"postal-code": [
"3040"
]
}
}
]
}
}'
JSON.parse(json, symbolize_names: true)
}
it "parses the request" do
Timecop.freeze do
result = subject.call(params: params)
expect(result).to be_a Adamantium::Entities::CheckinRequest
end
end
end
end

View File

@@ -58,4 +58,21 @@ RSpec.describe "Post creation", :db, :requests do
expect(post_repo.bookmark_listing.count).to eq 1
end
end
context "auth" do
it "does not allow multiple auth methods" do
params = {
access_token: "foo"
}
headers = {
HTTP_AUTHORIZATION: "Bearer foo",
CONTENT_TYPE: "application/json"
}
post "/micropub", params.to_json, headers
expect(last_response.status).to eq 400
end
end
end