-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce multisite tests for better coverage.
- Loading branch information
Showing
6 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
second: | ||
adapter: postgresql | ||
database: discourse_test_multisite | ||
host_names: | ||
- test2.localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Multisite SiteSettings' do | ||
let(:conn) { RailsMultisite::ConnectionManagement } | ||
|
||
before do | ||
@original_provider = SiteSetting.provider | ||
SiteSetting.provider = SiteSettings::DbProvider.new(SiteSetting) | ||
conn.config_filename = "spec/fixtures/multisite/two_dbs.yml" | ||
conn.load_settings! | ||
end | ||
|
||
after do | ||
['default', 'second'].each do |db| | ||
conn.with_connection(db) { SiteSetting.destroy_all } | ||
end | ||
|
||
conn.clear_settings! | ||
|
||
[:@@db_spec_cache, :@@host_spec_cache, :@@default_spec].each do |class_variable| | ||
conn.remove_class_variable(class_variable) | ||
end | ||
|
||
SiteSetting.provider = @original_provider | ||
end | ||
|
||
describe '#default_locale' do | ||
it 'should return the right locale' do | ||
conn.with_connection('default') do | ||
expect(SiteSetting.default_locale).to eq('en') | ||
end | ||
|
||
conn.with_connection('second') do | ||
SiteSetting.default_locale = 'zh_TW' | ||
|
||
expect(SiteSetting.default_locale).to eq('zh_TW') | ||
end | ||
|
||
conn.with_connection('default') do | ||
expect(SiteSetting.default_locale).to eq('en') | ||
|
||
SiteSetting.default_locale = 'ja' | ||
|
||
expect(SiteSetting.default_locale).to eq('ja') | ||
end | ||
|
||
conn.with_connection('second') do | ||
expect(SiteSetting.default_locale).to eq('zh_TW') | ||
end | ||
end | ||
end | ||
end |
2c39743
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on Discourse Meta. There might be relevant details there:
https://meta.discourse.org/t/failing-tests-in-discourse-dev-due-to-multisite/68720/1