2021-08-26 05:53:46 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-12-23 15:36:08 -05:00
|
|
|
require "rails_helper"
|
2021-08-26 05:53:46 -04:00
|
|
|
|
|
|
|
RSpec.describe ListController do
|
|
|
|
fab!(:p1) { Fabricate(:post) }
|
|
|
|
fab!(:p2) { Fabricate(:post, topic: p1.topic) }
|
|
|
|
fab!(:p3) { Fabricate(:post, topic: p1.topic) }
|
|
|
|
|
2022-12-23 15:36:08 -05:00
|
|
|
before { SiteSetting.allow_solved_on_all_topics = true }
|
2021-08-26 05:53:46 -04:00
|
|
|
|
2022-12-23 15:36:08 -05:00
|
|
|
it "shows the user who posted the accepted answer second" do
|
2021-08-26 05:53:46 -04:00
|
|
|
TopicFeaturedUsers.ensure_consistency!
|
|
|
|
DiscourseSolved.accept_answer!(p3, p1.user, topic: p1.topic)
|
|
|
|
|
2022-12-23 15:36:08 -05:00
|
|
|
get "/latest.json"
|
2021-08-26 05:53:46 -04:00
|
|
|
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
|