Fixing tests
This commit is contained in:
@@ -4,16 +4,16 @@ div class="h-card prose dark:prose-invert mb-12 prose-a:decoration-wavy hover:pr
|
||||
|
||||
div class="mb-8 max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
||||
|
||||
- if latest_status
|
||||
div class="mb-2 flex max-w-prose mx-auto"
|
||||
p Latest status
|
||||
div class="mb-12 p-2 grid grid-cols-7 gap-4 min-h-16 max-w-prose mx-auto bg-fuchsia-100 dark:bg-fuchsia-800 dark:text-gray-200 rounded"
|
||||
div class="col-span-4 sm:col-span-6 text-left"
|
||||
a class="block my-auto hover:underline decoration-wavy" href=latest_status.permalink
|
||||
== "#{latest_status.content}"
|
||||
== latest_status.content
|
||||
a class="col-span-3 sm:col-span-1 px-2 text-center transition-colors rounded bg-fuchsia-50 hover:bg-fuchsia-200 dark:bg-fuchsia-900 dark:hover:bg-fuchsia-700 inline-block grid content-center max-h-12 my-auto" href="/statuses"
|
||||
p See all
|
||||
|
||||
|
||||
div class="mb-4 flex max-w-prose mx-auto"
|
||||
h2 class="text-l text-gray-600 dark:text-gray-200" Posts
|
||||
a class="text-right flex-1 text-blue-400 dark:text-blue-200 hover:text-blue-600" href="/posts" See all →
|
||||
@@ -30,6 +30,7 @@ div class="grid grid-cols-3 gap-4 max-w-prose mx-auto"
|
||||
- photo_posts.each do |post|
|
||||
== render :photo_post, post: post
|
||||
|
||||
- if last_location
|
||||
div class="mb-12 mt-6 max-w-prose mx-auto text-gray-600 dark:text-gray-200 rounded p-2 bg-blue-50 dark:bg-blue-900/60"
|
||||
div
|
||||
= "🗺️ Last seen at "
|
||||
|
@@ -23,11 +23,11 @@ module Adamantium
|
||||
end
|
||||
|
||||
expose :latest_status do
|
||||
Decorators::Posts::Decorator.new(post_repo.latest_status)
|
||||
post_repo.latest_status ? Decorators::Posts::Decorator.new(post_repo.latest_status) : nil
|
||||
end
|
||||
|
||||
expose :last_location do
|
||||
Decorators::Posts::Decorator.new(post_repo.last_location)
|
||||
post_repo.last_location ? Decorators::Posts::Decorator.new(post_repo.last_location) : nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -3,6 +3,7 @@ require "digest"
|
||||
require "tempfile"
|
||||
require "open-uri"
|
||||
require "dry/monads"
|
||||
require "sanitize"
|
||||
|
||||
module Adamantium
|
||||
module Client
|
||||
@@ -18,7 +19,7 @@ module Adamantium
|
||||
content = if post[:name]
|
||||
"#{post[:name]} — #{settings.micropub_site_url}/post/#{post[:slug]}"
|
||||
else
|
||||
post[:content]
|
||||
sanitze_post(post[:content])
|
||||
end
|
||||
|
||||
tags = post[:category].map { |tag| "##{tag}" }.join(" ")
|
||||
@@ -74,6 +75,19 @@ module Adamantium
|
||||
|
||||
JSON.parse(response.body, symbolize_names: true).fetch(:id, nil)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sanitze_post(content)
|
||||
replace_links = lambda { |env|
|
||||
return unless env[:node_name] == "a"
|
||||
node = env[:node]
|
||||
url = node[:href]
|
||||
env[:node].replace(url)
|
||||
}
|
||||
|
||||
Sanitize.fragment(content, transformers: [replace_links]).strip
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -38,8 +38,8 @@ RSpec.describe "Post creation", :db, :requests do
|
||||
post "/micropub", params
|
||||
|
||||
expect(last_response).to be_successful
|
||||
expect(post_repo.post_listing.count).to eq 1
|
||||
expect(post_repo.post_listing.first.tags.map(&:label)).to eq ["ruby", "rspec"]
|
||||
expect(post_repo.statuses_listing.count).to eq 1
|
||||
expect(post_repo.statuses_listing.first.tags.map(&:label)).to eq ["ruby", "rspec"]
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user