mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Users can feature any public topic on his/her profile (#8809)
This commit is contained in:
committed by
GitHub
parent
de2e857de6
commit
e29fef9e99
@@ -3895,6 +3895,7 @@ describe UsersController do
|
||||
|
||||
describe '#feature_topic' do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:other_topic) { Fabricate(:topic) }
|
||||
fab!(:other_user) { Fabricate(:user) }
|
||||
fab!(:private_message) { Fabricate(:private_message_topic, user: other_user) }
|
||||
fab!(:category) { Fabricate(:category_with_definition) }
|
||||
@@ -3909,14 +3910,7 @@ describe UsersController do
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it 'returns an error if the the current user does not have access' do
|
||||
sign_in(user)
|
||||
topic.update(user_id: other_user.id)
|
||||
put "/u/#{user.username}/feature-topic.json", params: { topic_id: topic.id }
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it 'returns an error if the user did not create the topic' do
|
||||
it 'returns an error if the user tries to set for another user' do
|
||||
sign_in(user)
|
||||
topic.update(user_id: other_user.id)
|
||||
put "/u/#{other_user.username}/feature-topic.json", params: { topic_id: topic.id }
|
||||
@@ -3937,7 +3931,7 @@ describe UsersController do
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it 'sets the user_profiles featured_topic correctly' do
|
||||
it 'sets featured_topic correctly for user created topic' do
|
||||
sign_in(user)
|
||||
topic.update(user_id: user.id)
|
||||
put "/u/#{user.username}/feature-topic.json", params: { topic_id: topic.id }
|
||||
@@ -3945,6 +3939,13 @@ describe UsersController do
|
||||
expect(user.user_profile.featured_topic).to eq topic
|
||||
end
|
||||
|
||||
it 'sets featured_topic correctly for non-user-created topic' do
|
||||
sign_in(user)
|
||||
put "/u/#{user.username}/feature-topic.json", params: { topic_id: other_topic.id }
|
||||
expect(response.status).to eq(200)
|
||||
expect(user.user_profile.featured_topic).to eq other_topic
|
||||
end
|
||||
|
||||
describe "site setting disabled" do
|
||||
before do
|
||||
SiteSetting.allow_featured_topic_on_user_profiles = false
|
||||
|
||||
Reference in New Issue
Block a user