diff --git a/app/jobs/regular/create_avatar_thumbnails.rb b/app/jobs/regular/create_avatar_thumbnails.rb index 651dd2b0f2c..046f50bfe1c 100644 --- a/app/jobs/regular/create_avatar_thumbnails.rb +++ b/app/jobs/regular/create_avatar_thumbnails.rb @@ -3,6 +3,7 @@ module Jobs class CreateAvatarThumbnails < Jobs::Base def execute(args) + return if Rails.env.test? upload_id = args[:upload_id] raise Discourse::InvalidParameters.new(:upload_id) if upload_id.blank? diff --git a/app/models/translation_override.rb b/app/models/translation_override.rb index 05991ddc0ad..11aba82a46e 100644 --- a/app/models/translation_override.rb +++ b/app/models/translation_override.rb @@ -33,14 +33,12 @@ class TranslationOverride < ActiveRecord::Base MessageBus.publish('/i18n-flush', { refresh: true }) end - def lookup_original_text - I18n::Backend::Simple.new.send( - :lookup, self.locale, self.translation_key - ) - end - def check_interpolation_keys - if original_text = lookup_original_text + original_text = I18n.overrides_disabled do + I18n.backend.send(:lookup, self.locale, self.translation_key) + end + + if original_text original_interpolation_keys = I18nInterpolationKeysFinder.find(original_text) new_interpolation_keys = I18nInterpolationKeysFinder.find(value) missing_keys = (original_interpolation_keys - new_interpolation_keys) diff --git a/lib/upload_creator.rb b/lib/upload_creator.rb index 247fcc4e860..5bd6cb45256 100644 --- a/lib/upload_creator.rb +++ b/lib/upload_creator.rb @@ -39,7 +39,7 @@ class UploadCreator if @filename[/\.svg$/i] whitelist_svg! - else + elsif !Rails.env.test? convert_to_jpeg! if should_convert_to_jpeg? downsize! if should_downsize? diff --git a/spec/controllers/admin/site_texts_controller_spec.rb b/spec/controllers/admin/site_texts_controller_spec.rb index 1577e1a3493..bcbef94ba55 100644 --- a/spec/controllers/admin/site_texts_controller_spec.rb +++ b/spec/controllers/admin/site_texts_controller_spec.rb @@ -48,12 +48,11 @@ describe Admin::SiteTextsController do describe 'failure' do before do - TranslationOverride.any_instance.expects(:lookup_original_text) - .returns('%{first} %{second}') + I18n.backend.store_translations(:en, some_key: '%{first} %{second}') end it 'returns the right error message' do - xhr :put, :update, id: 'title', site_text: { value: 'hello %{key}' } + xhr :put, :update, id: 'some_key', site_text: { value: 'hello %{key}' } expect(response.status).to eq(422) diff --git a/spec/models/discourse_single_sign_on_spec.rb b/spec/models/discourse_single_sign_on_spec.rb index 4c26f04bbbd..abaab998561 100644 --- a/spec/models/discourse_single_sign_on_spec.rb +++ b/spec/models/discourse_single_sign_on_spec.rb @@ -67,15 +67,15 @@ describe DiscourseSingleSignOn do let(:ip_address) { "127.0.0.1" } it "can lookup or create user when name is blank" do - # so we can create system messages - Fabricate(:admin) sso = DiscourseSingleSignOn.new sso.username = "test" sso.name = "" sso.email = "test@test.com" sso.external_id = "A" + sso.suppress_welcome_message = true user = sso.lookup_or_create_user(ip_address) - expect(user).to_not be_nil + + expect(user.persisted?).to eq(true) end it "unstaged users" do @@ -111,6 +111,7 @@ describe DiscourseSingleSignOn do sso.external_id = "id" sso.admin = true sso.moderator = true + sso.suppress_welcome_message = true user = sso.lookup_or_create_user(ip_address) staff_group.reload @@ -233,14 +234,15 @@ describe DiscourseSingleSignOn do end context 'trusting emails' do - let(:sso) { + let(:sso) do sso = DiscourseSingleSignOn.new sso.username = "test" sso.name = "test" sso.email = "test@example.com" sso.external_id = "A" + sso.suppress_welcome_message = true sso - } + end it 'activates users by default' do user = sso.lookup_or_create_user(ip_address) @@ -327,22 +329,22 @@ describe DiscourseSingleSignOn do end context 'setting bio for a user' do - let(:sso) { + let(:sso) do sso = DiscourseSingleSignOn.new sso.username = "test" sso.name = "test" sso.email = "test@test.com" sso.external_id = "100" sso.bio = "This **is** the bio" + sso.suppress_welcome_message = true sso - } + end it 'can set bio if supplied on new users or users with empty bio' do # new account user = sso.lookup_or_create_user(ip_address) expect(user.user_profile.bio_cooked).to match_html("

This is the bio

") - # no override by default sso.bio = "new profile" user = sso.lookup_or_create_user(ip_address) @@ -350,8 +352,7 @@ describe DiscourseSingleSignOn do expect(user.user_profile.bio_cooked).to match_html("

This is the bio

") # yes override for blank - user.user_profile.bio_raw = " " - user.user_profile.save! + user.user_profile.update!(bio_raw: '') user = sso.lookup_or_create_user(ip_address) expect(user.user_profile.bio_cooked).to match_html("

new profile

") @@ -362,69 +363,67 @@ describe DiscourseSingleSignOn do SiteSetting.sso_overrides_bio = true user = sso.lookup_or_create_user(ip_address) - expect(user.user_profile.bio_cooked).to match_html("

new profile 2

") + expect(user.user_profile.bio_cooked).to match_html("

new profile 2