From c79418d334a316cd1261eee482b24aef52d18834 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 3 Jul 2017 15:22:44 -0400 Subject: [PATCH] DEV: Move RTL into lib where it belongs --- app/mailers/user_notifications.rb | 5 +++-- {app/models => lib}/rtl.rb | 2 +- spec/{models => components}/rtl_spec.rb | 17 ++++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) rename {app/models => lib}/rtl.rb (97%) rename spec/{models => components}/rtl_spec.rb (71%) diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index 44d1cc7bd24..3fa3f96a701 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -1,6 +1,7 @@ require_dependency 'markdown_linker' require_dependency 'email/message_builder' require_dependency 'age_words' +require_dependency 'rtl' class UserNotifications < ActionMailer::Base include UserNotificationsHelper @@ -392,7 +393,7 @@ class UserNotifications < ActionMailer::Base template: 'email/invite', format: :html, locals: { message: PrettyText.cook(message, sanitize: false).html_safe, - classes: RTL.new(user).css_class + classes: Rtl.new(user).css_class } ) end @@ -418,7 +419,7 @@ class UserNotifications < ActionMailer::Base reached_limit: reached_limit, post: post, in_reply_to_post: in_reply_to_post, - classes: RTL.new(user).css_class + classes: Rtl.new(user).css_class } ) end diff --git a/app/models/rtl.rb b/lib/rtl.rb similarity index 97% rename from app/models/rtl.rb rename to lib/rtl.rb index 79f48603e02..b6df383b587 100644 --- a/app/models/rtl.rb +++ b/lib/rtl.rb @@ -1,4 +1,4 @@ -class RTL +class Rtl attr_reader :user diff --git a/spec/models/rtl_spec.rb b/spec/components/rtl_spec.rb similarity index 71% rename from spec/models/rtl_spec.rb rename to spec/components/rtl_spec.rb index 74b3462cc1f..018fc6fdf46 100644 --- a/spec/models/rtl_spec.rb +++ b/spec/components/rtl_spec.rb @@ -1,25 +1,28 @@ require 'rails_helper' +require_dependency 'rtl' -describe RTL do +describe Rtl do let(:user) { Fabricate.build(:user) } describe '.css_class' do context 'user locale is allowed' do - before { SiteSetting.stubs(:allow_user_locale).returns(true) } + before { + SiteSetting.allow_user_locale = true + } context 'user locale is RTL' do - before { user.stubs(:locale).returns('he') } + before { user.locale = 'he' } it 'returns rtl class' do - expect(RTL.new(user).css_class).to eq('rtl') + expect(Rtl.new(user).css_class).to eq('rtl') end end context 'user locale is not RTL' do it 'returns empty class' do - expect(RTL.new(user).css_class).to eq('') + expect(Rtl.new(user).css_class).to eq('') end end @@ -32,7 +35,7 @@ describe RTL do before { SiteSetting.stubs(:default_locale).returns('he') } it 'returns rtl class' do - expect(RTL.new(user).css_class).to eq('rtl') + expect(Rtl.new(user).css_class).to eq('rtl') end end @@ -43,7 +46,7 @@ describe RTL do before { user.stubs(:locale).returns('he') } it 'returns empty class' do - expect(RTL.new(user).css_class).to eq('') + expect(Rtl.new(user).css_class).to eq('') end end end