mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-22 01:01:49 +08:00
Editing a post that's a reply produced a "The requested URL or resource
could not be found" dialog when the post had been viewed via its
parent's expanded replies list. The dialog came from a `PUT
/post_replies/:id` request that 404s; the URL should be `PUT
/posts/:id`.
`loadMoreReplies` calls `store.find("post-reply", …)` then
`store.createRecord("post", reply)` on each result. The first stamps
`__type = "post-reply"` (and `__munge`, `__state`) onto each model. The
second re-hydrates the same `id` under `post` — and the topic stream's
canonical post for that `id` is already in the store. `_hydrate`'s
"update existing" path copies those internal fields onto the canonical
record via `setProperties`, so a later `post.save()` builds its URL from
the wrong `__type`.
Fix: skip every `__`-prefixed key when diffing in `_hydrate`'s update
path. Internal store/RestModel metadata stamped at hydration time has no
business being carried across types. The `__` prefix is the existing
convention for "internal", so future additions are protected by the same
guard.
https://meta.discourse.org/t/402747
93 lines
2.1 KiB
Ruby
Vendored
93 lines
2.1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Components
|
|
class Post < PageObjects::Components::Base
|
|
def initialize(post_number)
|
|
@post_number = post_number
|
|
end
|
|
|
|
def post
|
|
find(post_id)
|
|
end
|
|
|
|
def reply
|
|
post.find(".reply.create").click
|
|
end
|
|
|
|
def edit
|
|
post.find(".show-more-actions").click
|
|
post.find("button.edit").click
|
|
end
|
|
|
|
def show_replies
|
|
post.find(".show-replies").click
|
|
end
|
|
|
|
def jump_to_reply(reply)
|
|
find(
|
|
"#embedded-posts__bottom--#{@post_number} .reply[data-post-id='#{reply.id}'] a.post-info.arrow",
|
|
).click
|
|
end
|
|
|
|
def load_more_replies
|
|
find("#embedded-posts__bottom--#{@post_number} .load-more-replies").click
|
|
end
|
|
|
|
def cooked_content
|
|
post.find(".contents > .cooked")
|
|
end
|
|
|
|
def has_cooked_content?(value)
|
|
cooked_content.has_content?(value)
|
|
end
|
|
|
|
def has_replies?(count: nil)
|
|
find("#embedded-posts__bottom--#{@post_number}").has_css?(".reply", count:)
|
|
end
|
|
|
|
def has_more_replies?
|
|
find("#embedded-posts__bottom--#{@post_number}").has_css?(".load-more-replies")
|
|
end
|
|
|
|
def has_loaded_all_replies?
|
|
find("#embedded-posts__bottom--#{@post_number}").has_no_css?(".load-more-replies")
|
|
end
|
|
|
|
def visible?
|
|
has_css?(post_id)
|
|
end
|
|
|
|
def show_parent_posts
|
|
post.find(".reply-to-tab").click
|
|
end
|
|
|
|
def has_parent_posts?(count: nil)
|
|
find("#embedded-posts__top--#{@post_number}").has_css?(".reply", count:)
|
|
end
|
|
|
|
def has_no_parent_post_content?(content)
|
|
find("#embedded-posts__top--#{@post_number}").has_no_content?(content)
|
|
end
|
|
|
|
def post_language
|
|
post.find(".post-info.post-language").hover
|
|
find(".post-language-content")
|
|
end
|
|
|
|
def open_post_history
|
|
post.find(".post-info.edits").click
|
|
end
|
|
|
|
def mentions_of(user)
|
|
post.all("a.mention[href='/u/#{user.username}']")
|
|
end
|
|
|
|
private
|
|
|
|
def post_id
|
|
"#post_#{@post_number}"
|
|
end
|
|
end
|
|
end
|
|
end
|