From 7e06bea0d791d8a184da3e526a850081c9bed9bb Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 12 Sep 2010 14:40:31 +0200 Subject: [PATCH] Converted tolk to mountable engine 2 tests still fail and integration tests must be run with selenium because of bug in capybara. --- .gitignore | 5 +- Gemfile | 16 + Rakefile | 43 +- .../tolk/application_controller.rb | 2 +- app/models/tolk/locale.rb | 2 +- app/views/layouts/tolk/application.html.erb | 2 +- app/views/tolk/locales/all.html.erb | 2 +- app/views/tolk/locales/index.html.erb | 1 - app/views/tolk/locales/show.html.erb | 6 +- app/views/tolk/searches/show.html.erb | 2 +- config/boot.rb | 109 - config/environment.rb | 16 - config/environments/development.rb | 17 - config/environments/production.rb | 24 - config/environments/test.rb | 22 - config/initializers/mime_types.rb | 1 - config/initializers/new_rails_defaults.rb | 17 - config/routes.rb | 13 +- lib/tolk.rb | 2 + lib/tolk/engine.rb | 2 +- test/dummy/Rakefile | 7 + .../app/controllers/application_controller.rb | 3 + test/dummy/app/helpers/application_helper.rb | 2 + .../app/views/layouts/application.html.erb | 14 + test/dummy/config.ru | 4 + test/dummy/config/application.rb | 45 + test/dummy/config/boot.rb | 10 + {config => test/dummy/config}/database.yml | 0 test/dummy/config/environment.rb | 5 + test/dummy/config/environments/development.rb | 26 + test/dummy/config/environments/production.rb | 49 + test/dummy/config/environments/test.rb | 35 + .../initializers/backtrace_silencers.rb | 7 + .../dummy/config}/initializers/inflections.rb | 2 +- test/dummy/config/initializers/mime_types.rb | 5 + .../dummy/config/initializers/secret_token.rb | 7 + .../config/initializers/session_store.rb | 8 + test/dummy/config/locales/sync/.gitkeep | 0 test/dummy/config/routes.rb | 3 + test/dummy/db/development.sqlite3 | Bin 0 -> 18432 bytes test/dummy/db/migrate/.gitkeep | 0 .../20100912123407_create_phrases.blog.rb | 13 + .../20100912123408_create_locales.blog.rb | 13 + ...20100912123409_create_translations.blog.rb | 15 + .../20100912123410_create_systems.blog.rb | 14 + ...0100912123411_add_system_to_locale.blog.rb | 9 + ...412_rename_systems_to_applications.blog.rb | 11 + ...3413_add_application_id_to_phrases.blog.rb | 9 + .../20100912123414_drop_applications.blog.rb | 19 + .../20100912123415_add_updated_stuff.blog.rb | 11 + .../20100912123416_rename_tables.blog.rb | 13 + ...20100912123417_add_missing_indices.blog.rb | 11 + test/dummy/db/schema.rb | 41 + test/dummy/db/test.sqlite3 | Bin 0 -> 18432 bytes test/dummy/log/development.log | 618 + test/dummy/log/production.log | 0 test/dummy/log/server.log | 0 test/dummy/log/test.log | 56357 ++++++++++++++++ test/dummy/public/404.html | 26 + test/dummy/public/422.html | 26 + test/dummy/public/500.html | 26 + test/dummy/public/favicon.ico | 0 test/dummy/public/javascripts/application.js | 2 + test/dummy/public/javascripts/controls.js | 965 + test/dummy/public/javascripts/dragdrop.js | 974 + test/dummy/public/javascripts/effects.js | 1123 + test/dummy/public/javascripts/prototype.js | 6001 ++ test/dummy/public/javascripts/rails.js | 175 + test/dummy/public/stylesheets/.gitkeep | 0 test/dummy/script/rails | 6 + test/integration/authentication_test.rb | 3 + test/integration/translation_process_test.rb | 18 +- test/locales/basic/da.yml | 4 +- test/locales/basic/se.yml | 2 +- .../active_record_shared_connections.rb | 12 + test/support/integration_case.rb | 6 + test/support/test_case.rb | 8 + test/test_helper.rb | 36 +- test/unit/format_test.rb | 6 +- test/unit/locale_test.rb | 16 +- test/unit/sync_test.rb | 34 +- test/unit/translation_test.rb | 5 +- 82 files changed, 66881 insertions(+), 283 deletions(-) delete mode 100644 config/boot.rb delete mode 100644 config/environment.rb delete mode 100644 config/environments/development.rb delete mode 100644 config/environments/production.rb delete mode 100644 config/environments/test.rb delete mode 100644 config/initializers/mime_types.rb delete mode 100644 config/initializers/new_rails_defaults.rb create mode 100644 test/dummy/Rakefile create mode 100644 test/dummy/app/controllers/application_controller.rb create mode 100644 test/dummy/app/helpers/application_helper.rb create mode 100644 test/dummy/app/views/layouts/application.html.erb create mode 100644 test/dummy/config.ru create mode 100644 test/dummy/config/application.rb create mode 100644 test/dummy/config/boot.rb rename {config => test/dummy/config}/database.yml (100%) create mode 100644 test/dummy/config/environment.rb create mode 100644 test/dummy/config/environments/development.rb create mode 100644 test/dummy/config/environments/production.rb create mode 100644 test/dummy/config/environments/test.rb create mode 100644 test/dummy/config/initializers/backtrace_silencers.rb rename {config => test/dummy/config}/initializers/inflections.rb (85%) create mode 100644 test/dummy/config/initializers/mime_types.rb create mode 100644 test/dummy/config/initializers/secret_token.rb create mode 100644 test/dummy/config/initializers/session_store.rb create mode 100644 test/dummy/config/locales/sync/.gitkeep create mode 100644 test/dummy/config/routes.rb create mode 100644 test/dummy/db/development.sqlite3 create mode 100644 test/dummy/db/migrate/.gitkeep create mode 100644 test/dummy/db/migrate/20100912123407_create_phrases.blog.rb create mode 100644 test/dummy/db/migrate/20100912123408_create_locales.blog.rb create mode 100644 test/dummy/db/migrate/20100912123409_create_translations.blog.rb create mode 100644 test/dummy/db/migrate/20100912123410_create_systems.blog.rb create mode 100644 test/dummy/db/migrate/20100912123411_add_system_to_locale.blog.rb create mode 100644 test/dummy/db/migrate/20100912123412_rename_systems_to_applications.blog.rb create mode 100644 test/dummy/db/migrate/20100912123413_add_application_id_to_phrases.blog.rb create mode 100644 test/dummy/db/migrate/20100912123414_drop_applications.blog.rb create mode 100644 test/dummy/db/migrate/20100912123415_add_updated_stuff.blog.rb create mode 100644 test/dummy/db/migrate/20100912123416_rename_tables.blog.rb create mode 100644 test/dummy/db/migrate/20100912123417_add_missing_indices.blog.rb create mode 100644 test/dummy/db/schema.rb create mode 100644 test/dummy/db/test.sqlite3 create mode 100644 test/dummy/log/development.log create mode 100644 test/dummy/log/production.log create mode 100644 test/dummy/log/server.log create mode 100644 test/dummy/log/test.log create mode 100644 test/dummy/public/404.html create mode 100644 test/dummy/public/422.html create mode 100644 test/dummy/public/500.html create mode 100644 test/dummy/public/favicon.ico create mode 100644 test/dummy/public/javascripts/application.js create mode 100644 test/dummy/public/javascripts/controls.js create mode 100644 test/dummy/public/javascripts/dragdrop.js create mode 100644 test/dummy/public/javascripts/effects.js create mode 100644 test/dummy/public/javascripts/prototype.js create mode 100644 test/dummy/public/javascripts/rails.js create mode 100644 test/dummy/public/stylesheets/.gitkeep create mode 100755 test/dummy/script/rails create mode 100644 test/support/active_record_shared_connections.rb create mode 100644 test/support/integration_case.rb create mode 100644 test/support/test_case.rb diff --git a/.gitignore b/.gitignore index a83a5aef..68d9430f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -tmp/**/* \ No newline at end of file +tmp/**/* +test/dummy/db/migrate/*.tolk.rb +Gemfile.lock +.bundle diff --git a/Gemfile b/Gemfile index 86b754f6..7f3abe96 100644 --- a/Gemfile +++ b/Gemfile @@ -1 +1,17 @@ +source "http://rubygems.org" + +gem "rails", :git => "http://github.com/rails/rails.git" +gem "arel", :git => "http://github.com/rails/arel.git" + gem 'will_paginate', :git => 'http://github.com/mislav/will_paginate.git', :branch => 'rails3' +gem "ya2yaml" + +gem "factory_girl_rails" +gem "capybara", ">= 0.3.9" +gem "sqlite3-ruby", :require => "sqlite3" +gem "mocha" + +if RUBY_VERSION < '1.9' + gem "ruby-debug", ">= 0.10.3" +end + diff --git a/Rakefile b/Rakefile index 3bb0e859..509f7d01 100644 --- a/Rakefile +++ b/Rakefile @@ -1,10 +1,39 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require(File.join(File.dirname(__FILE__), 'config', 'boot')) - +# encoding: UTF-8 require 'rake' -require 'rake/testtask' require 'rake/rdoctask' +require 'rake/gempackagetask' + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + +task :default => :test + +Rake::RDocTask.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'Tolk' + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +spec = Gem::Specification.new do |s| + s.name = "tolk" + s.summary = "Rails engine providing web interface for managing i18n yaml files" + s.description = "Tolk is a web interface for doing i18n translations packaged as an engine for Rails applications." + s.files = FileList["[A-Z]*", "lib/**/*"] + s.version = "2.0.0.beta" +end + +Rake::GemPackageTask.new(spec) do |pkg| +end -require 'tasks/rails' +desc "Install the gem #{spec.name}-#{spec.version}.gem" +task :install do + system("gem install pkg/#{spec.name}-#{spec.version}.gem --no-ri --no-rdoc") +end diff --git a/app/controllers/tolk/application_controller.rb b/app/controllers/tolk/application_controller.rb index 2564b9b2..4dda8593 100644 --- a/app/controllers/tolk/application_controller.rb +++ b/app/controllers/tolk/application_controller.rb @@ -11,7 +11,7 @@ def authenticate end def ensure_no_primary_locale - redirect_to tolk_locales_path if @locale.primary? + redirect_to tolk.locales_path if @locale.primary? end end end diff --git a/app/models/tolk/locale.rb b/app/models/tolk/locale.rb index 36e8eb45..3d3a4d44 100644 --- a/app/models/tolk/locale.rb +++ b/app/models/tolk/locale.rb @@ -133,7 +133,7 @@ def phrases_without_translation(page = nil, options = {}) existing_ids = self.translations.all(:select => 'tolk_translations.phrase_id').map(&:phrase_id).uniq phrases = phrases.scoped(:conditions => ['tolk_phrases.id NOT IN (?)', existing_ids]) if existing_ids.present? - result = phrases.paginate({:page => page}.merge(options)) + result = phrases.paginate({:page => page, :per_page => Phrase.per_page}.merge(options)) Tolk::Phrase.send :preload_associations, result, :translations result end diff --git a/app/views/layouts/tolk/application.html.erb b/app/views/layouts/tolk/application.html.erb index 97912ca9..5e19615f 100644 --- a/app/views/layouts/tolk/application.html.erb +++ b/app/views/layouts/tolk/application.html.erb @@ -19,7 +19,7 @@
<%= yield %>
diff --git a/app/views/tolk/locales/all.html.erb b/app/views/tolk/locales/all.html.erb index 98e807da..0b5407a3 100644 --- a/app/views/tolk/locales/all.html.erb +++ b/app/views/tolk/locales/all.html.erb @@ -4,7 +4,7 @@

Completed translations (<%= link_to 'See phrases missing translation', @locale %>)

<% if @locale.has_updated_translations? && action_name != 'updated' %> - Some phrases have changed. <%= link_to "Update translations", updated_tolk_locale_path(@locale) %>. + Some phrases have changed. <%= link_to "Update translations", tolk.updated_locale_path(@locale) %>. <% end %>