DEV: Move RTL into lib where it belongs

This commit is contained in:
Sam 2017-07-03 15:22:44 -04:00
parent 984778d3ac
commit c79418d334
3 changed files with 14 additions and 10 deletions

View File

@ -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

View File

@ -1,4 +1,4 @@
class RTL
class Rtl
attr_reader :user

View File

@ -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