Changeset 0cbd7353bfa01b4f1e3ffd78bc098fe434ac4e36
- Timestamp:
- 07/28/10 11:45:38 (6 weeks ago)
- Author:
- Alban Peignier <alban.peignier@…>
- Parents:
- 9c0140d30eb37fa37a5108d371ef26b82b3675a1, fa9b78b4f288d57831f48eabfed053a5653b31f7
- git-committer:
- Alban Peignier <alban.peignier@free.fr> / 2010-07-28T11:45:38Z+0200
- Message:
-
Merge branch 'master' of www.dbx.tryphon.priv:/srv/git/user_interface
Conflicts:
spec/locale_management_spec.rb
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r8eb5c0b
|
rbea1a52
|
|
| 1 | 1 | # Include hook code here |
| 2 | 2 | require 'user_interface' |
| | 3 | |
| | 4 | config.to_prepare do |
| | 5 | ApplicationController.helper LanguagesHelper |
| | 6 | |
| | 7 | ActionView::Base.send :include, UserInterface::FlashHelper |
| | 8 | ActionView::Base.send :include, UserInterface::TitleHelper |
| | 9 | |
| | 10 | if defined?(WillPaginate::ViewHelpers) |
| | 11 | require 'user_interface/helpers/will_paginate_helper' |
| | 12 | ActionView::Base.send :include, UserInterface::WillPaginateHelper |
| | 13 | end |
| | 14 | end |
| | 15 | |
| | 16 | |
-
|
r01a5018
|
rbea1a52
|
|
| 8 | 8 | require 'user_interface/helpers/flash_helper' |
| 9 | 9 | require 'user_interface/helpers/title_helper' |
| 10 | | |
| 11 | | if defined?(ActionView::Base) |
| 12 | | ActionView::Base.send :include, UserInterface::FlashHelper |
| 13 | | ActionView::Base.send :include, UserInterface::TitleHelper |
| 14 | | end |
| 15 | | |
-
|
r01a5018
|
rd7c8ed2
|
|
| 10 | 10 | |
| 11 | 11 | def change_locale |
| 12 | | I18n.locale = params[:lang] if params[:lang] |
| | 12 | if params[:lang] |
| | 13 | logger.debug "Overrides session language with param lang : #{params[:lang]}" |
| | 14 | user_session.language = params[:lang] |
| | 15 | end |
| | 16 | I18n.locale = user_session.language |
| 13 | 17 | end |
| 14 | 18 | |
-
|
r9c0140d
|
rd7c8ed2
|
|
| 15 | 15 | end |
| 16 | 16 | |
| | 17 | attr_reader :user_session |
| | 18 | def initialize(user_session) |
| | 19 | @user_session = user_session |
| | 20 | end |
| | 21 | |
| | 22 | def params |
| | 23 | {} |
| | 24 | end |
| | 25 | |
| | 26 | def logger |
| | 27 | Rails.logger |
| | 28 | end |
| | 29 | |
| 17 | 30 | include UserInterface::LocaleManagement |
| 18 | 31 | end |
| 19 | 32 | |
| 20 | | before(:each) do |
| 21 | | @locale_management = TestLocaleManagement.new |
| | 33 | let(:user_session) { mock UserInterface::UserSession, :language => :fr, :language= => nil } |
| | 34 | let(:locale_management) { TestLocaleManagement.new user_session } |
| | 35 | |
| | 36 | it "should add a before_filter :change_locale" do |
| | 37 | locale_management.before_filters.should == [ :change_locale ] |
| 22 | 38 | end |
| 23 | 39 | |
| 24 | | it "should add a before_filter :change_locale" do |
| 25 | | @locale_management.before_filters.should == [ :change_locale ] |
| | 40 | it "should change I18n.locale to UserSession#langague" do |
| | 41 | locale_management.send(:change_locale) |
| | 42 | I18n.locale.should == user_session.language |
| 26 | 43 | end |
| 27 | 44 | |
| 28 | | it "should change I18n.locale with params :lang" do |
| 29 | | @locale_management.stub!(:params).and_return(:lang => "fr") |
| 30 | | @locale_management.send(:change_locale) |
| 31 | | I18n.locale.should == :fr |
| | 45 | context 'when params :lang is present' do |
| | 46 | |
| | 47 | before(:each) do |
| | 48 | locale_management.stub!(:params).and_return(:lang => "dummy") |
| | 49 | end |
| | 50 | |
| | 51 | it "should change UserSession#language" do |
| | 52 | user_session.should_receive(:language=).with("dummy") |
| | 53 | locale_management.send(:change_locale) |
| | 54 | end |
| | 55 | |
| 32 | 56 | end |
| 33 | 57 | |
-
|
r2bc635c
|
rbea1a52
|
|
| 248 | 248 | background: url("../images/ui/tags.png") no-repeat 0px 6px; |
| 249 | 249 | } |
| | 250 | |
| | 251 | .inline_help { |
| | 252 | padding-left: 20px; |
| | 253 | font-size: 90%; |
| | 254 | font-style: italic; |
| | 255 | background: url("../images/ui/help.png") no-repeat; |
| | 256 | margin-top: 20px; |
| | 257 | |
| | 258 | p { |
| | 259 | margin: 6px 0; |
| | 260 | } |
| | 261 | } |
| | 262 | |
| 250 | 263 | } |
| 251 | 264 | |
| … |
… |
|
| 272 | 285 | font-size: 90%; |
| 273 | 286 | margin: 4px 0; |
| | 287 | } |
| | 288 | p.languages { |
| | 289 | margin: -5px 0 10px 0; |
| | 290 | padding: 0px; |
| | 291 | text-align: center; |
| 274 | 292 | } |
| 275 | 293 | form.search { |
| … |
… |
|
| 379 | 397 | } |
| 380 | 398 | |
| | 399 | ul li { |
| | 400 | padding: 0 !important; |
| | 401 | margin-left: 0 !important; |
| | 402 | } |
| | 403 | |
| 381 | 404 | .textile_editor_help { |
| 382 | 405 | padding: 4px 0 10px 10px; |