mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: improve usability of subfolder specs
Previously people were not consistent about mocking which left internals in a fragile state when running subfolder specs. This introduces a simple helper `set_subfolder` which you can use to set the subfolder for the spec. It takes care of proper configuration of subfolder and teardown. ``` # usage set_subfolder "/my_amazing_subfolder" ``` You should no longer stub base_uri or global_settings
This commit is contained in:
@ -1861,7 +1861,8 @@ RSpec.describe TopicsController do
|
||||
|
||||
describe 'clear_notifications' do
|
||||
it 'correctly clears notifications if specified via cookie' do
|
||||
Discourse.stubs(:base_uri).returns("/eviltrout")
|
||||
set_subfolder "/eviltrout"
|
||||
|
||||
notification = Fabricate(:notification)
|
||||
sign_in(notification.user)
|
||||
|
||||
@ -2146,8 +2147,7 @@ RSpec.describe TopicsController do
|
||||
end
|
||||
|
||||
it 'renders rss of the topic correctly with subfolder' do
|
||||
GlobalSetting.stubs(:relative_url_root).returns('/forum')
|
||||
Discourse.stubs(:base_uri).returns("/forum")
|
||||
set_subfolder "/forum"
|
||||
get "/t/foo/#{topic.id}.rss"
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.body).to_not include("/forum/forum")
|
||||
|
Reference in New Issue
Block a user