mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 19:22:18 +08:00
Extracts `accept_answer!` and `unaccept_answer!` from plugin.rb and moves the logic into separate service objects, along with adding more detailed test coverage for each service. --------- Co-authored-by: Loïc Guitaut <loic@discourse.org>
21 lines
780 B
Ruby
Vendored
21 lines
780 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
RSpec.describe ListController do
|
|
fab!(:p1, :post)
|
|
fab!(:p2) { Fabricate(:post, topic: p1.topic) }
|
|
fab!(:p3) { Fabricate(:post, topic: p1.topic) }
|
|
|
|
before { SiteSetting.allow_solved_on_all_topics = true }
|
|
|
|
it "shows the user who posted the accepted answer second" do
|
|
TopicFeaturedUsers.ensure_consistency!
|
|
DiscourseSolved::AcceptAnswer.call!(params: { post_id: p3.id }, guardian: p1.user.guardian)
|
|
|
|
get "/latest.json"
|
|
posters = response.parsed_body["topic_list"]["topics"].first["posters"]
|
|
expect(posters[0]["user_id"]).to eq(p1.user_id)
|
|
expect(posters[1]["user_id"]).to eq(p3.user_id)
|
|
expect(posters[1]["description"]).to include("Accepted Answer")
|
|
expect(posters[2]["user_id"]).to eq(p2.user_id)
|
|
end
|
|
end
|