translation_center 1.7.2 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -2
- data/Rakefile +8 -13
- data/app/assets/javascripts/translation_center/application.js +1 -1
- data/app/assets/stylesheets/translation_center/application.css +1 -1
- data/app/assets/stylesheets/translation_center/translation_keys.css +3 -1
- data/app/controllers/translation_center/application_controller.rb +2 -2
- data/app/controllers/translation_center/translation_keys_controller.rb +4 -4
- data/app/models/translation_center/activity_query.rb +2 -3
- data/app/models/translation_center/category.rb +7 -2
- data/app/models/translation_center/translation.rb +54 -32
- data/app/models/translation_center/translation_key.rb +29 -18
- data/app/views/layouts/translation_center/application.html.haml +0 -2
- data/app/views/translation_center/translation_keys/_translation_keys.html.haml +3 -1
- data/app/views/translation_center/translations/_show.html.haml +3 -3
- data/config/routes.rb +3 -3
- data/db/development.sqlite3 +0 -0
- data/{test/dummy/db/migrate/20130410082611_devise_create_users.rb → db/migrate/20130410082600_devise_create_users.rb} +0 -0
- data/{test/dummy/db/migrate/20130410082701_create_articles.rb → db/migrate/20130410082601_create_articles.rb} +0 -0
- data/{test/dummy/db/migrate/20130410084711234392_create_translation_center_categories.rb → db/migrate/20130410084602_create_translation_center_categories.rb} +0 -0
- data/{test/dummy/db/migrate/20130410084711235054_create_translation_center_translation_keys.rb → db/migrate/20130410084603_create_translation_center_translation_keys.rb} +0 -0
- data/{test/dummy/db/migrate/20130410084711235601_create_translation_center_translations.rb → db/migrate/20130410084604_create_translation_center_translations.rb} +0 -0
- data/{test/dummy/db/migrate/20130410084711_acts_as_votable_migration.rb → db/migrate/20130410084605_acts_as_votable_migration.rb} +1 -0
- data/{test/dummy/db/migrate/20130410084711235602_install_audited.rb → db/migrate/20130410084606_install_audited.rb} +0 -0
- data/{test/dummy/db/migrate/20130410113111070575_add_de_status_translation_center_translation_keys.rb → db/migrate/20130410113607_add_de_status_translation_center_translation_keys.rb} +0 -0
- data/{test/dummy/db/migrate/20130417134539377014_add_ar_status_translation_center_translation_keys.rb → db/migrate/20130417134608_add_ar_status_translation_center_translation_keys.rb} +0 -0
- data/{test/dummy/db/migrate/20130506103956_fix_translation_user_relation.rb → db/migrate/20130506103609_fix_translation_user_relation.rb} +0 -0
- data/{test/dummy/db/migrate/20130801102022_add_indicies.rb → db/migrate/20130801102610_add_indicies.rb} +0 -0
- data/{test/dummy/db → db}/schema.rb +13 -13
- data/{test/dummy/public/favicon.ico → db/test.sqlite3} +0 -0
- data/lib/generators/translation_center/add_lang/add_lang_generator.rb +5 -2
- data/lib/generators/translation_center/install/install_generator.rb +4 -4
- data/lib/translation_center/acts_as_translator.rb +1 -1
- data/lib/translation_center/engine.rb +7 -0
- data/lib/translation_center/translation_helpers.rb +1 -1
- data/lib/translation_center/translations_transfer.rb +6 -5
- data/lib/translation_center/version.rb +1 -1
- data/spec/controllers/categories_controller_spec.rb +47 -0
- data/spec/controllers/center_controller_spec.rb +77 -0
- data/spec/controllers/translation_keys_controller_spec.rb +87 -0
- data/spec/controllers/translations_controller_spec.rb +70 -0
- data/{test → spec}/dummy/README.rdoc +0 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -1
- data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -1
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/{test → spec}/dummy/app/models/user.rb +2 -5
- data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -1
- data/{test → spec}/dummy/config.ru +0 -0
- data/{test → spec}/dummy/config/application.rb +10 -5
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/spec/dummy/config/database.yml +25 -0
- data/{test → spec}/dummy/config/environment.rb +2 -0
- data/{test → spec}/dummy/config/environments/development.rb +0 -0
- data/{test → spec}/dummy/config/environments/production.rb +0 -0
- data/{test → spec}/dummy/config/environments/test.rb +2 -2
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{test → spec}/dummy/config/initializers/devise.rb +3 -1
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/{test → spec}/dummy/config/initializers/secret_token.rb +1 -1
- data/{test → spec}/dummy/config/initializers/session_store.rb +1 -1
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/{test → spec}/dummy/config/locales/devise.en.yml +0 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/{test → spec}/dummy/config/translation_center.yml +23 -6
- data/spec/dummy/db/migrate/20130410082611_devise_create_users.translation_center.rb +46 -0
- data/spec/dummy/db/migrate/20130410082701_create_articles.translation_center.rb +10 -0
- data/spec/dummy/db/migrate/20130410084702_create_translation_center_categories.translation_center.rb +9 -0
- data/spec/dummy/db/migrate/20130410084703_create_translation_center_translation_keys.translation_center.rb +14 -0
- data/spec/dummy/db/migrate/20130410084704_create_translation_center_translations.translation_center.rb +13 -0
- data/spec/dummy/db/migrate/20130410084711_acts_as_votable_migration.translation_center.rb +24 -0
- data/spec/dummy/db/migrate/20130410084712_install_audited.translation_center.rb +28 -0
- data/spec/dummy/db/migrate/20130410113113_add_de_status_translation_center_translation_keys.translation_center.rb +5 -0
- data/spec/dummy/db/migrate/20130417134534_add_ar_status_translation_center_translation_keys.rb +5 -0
- data/spec/dummy/db/migrate/20130506103956_fix_translation_user_relation.translation_center.rb +12 -0
- data/spec/dummy/db/migrate/20130801102021_add_indicies.translation_center.rb +8 -0
- data/spec/dummy/db/schema.rb +111 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/{test → spec}/dummy/script/rails +0 -0
- data/spec/factories/category_factory.rb +5 -0
- data/spec/factories/translation_factory.rb +8 -0
- data/spec/factories/translation_key_factory.rb +5 -0
- data/spec/factories/user_factory.rb +6 -0
- data/spec/factories/vote_factory.rb +13 -0
- data/spec/lib/generators/translation_center/add_lang/add_lang_generator_spec.rb +26 -0
- data/spec/models/translation_center/category_spec.rb +39 -0
- data/spec/models/translation_center/translation_key_spec.rb +145 -0
- data/spec/models/translation_center/translation_spec.rb +117 -0
- data/spec/schema.rb +112 -0
- data/spec/spec_helper.rb +52 -0
- data/spec/support/devise.rb +3 -0
- metadata +360 -208
- data/test/dummy/app/assets/images/translation_center_logo.png +0 -0
- data/test/dummy/app/assets/javascripts/articles.js +0 -2
- data/test/dummy/app/assets/stylesheets/articles.css +0 -4
- data/test/dummy/app/assets/stylesheets/scaffold.css +0 -56
- data/test/dummy/app/controllers/application_controller.rb +0 -6
- data/test/dummy/app/controllers/articles_controller.rb +0 -85
- data/test/dummy/app/helpers/articles_helper.rb +0 -2
- data/test/dummy/app/models/article.rb +0 -7
- data/test/dummy/app/views/articles/_form.html.haml +0 -16
- data/test/dummy/app/views/articles/edit.html.haml +0 -7
- data/test/dummy/app/views/articles/index.html.haml +0 -32
- data/test/dummy/app/views/articles/new.html.haml +0 -5
- data/test/dummy/app/views/articles/show.html.haml +0 -14
- data/test/dummy/config/database.yml +0 -42
- data/test/dummy/config/locales/ar.yml +0 -6
- data/test/dummy/config/locales/de.yml +0 -2
- data/test/dummy/config/locales/en.yml +0 -361
- data/test/dummy/config/routes.rb +0 -10
- data/test/dummy/spec/spec_helper.rb +0 -38
- data/test/dummy/test/fixtures/articles.yml +0 -9
- data/test/dummy/test/fixtures/posts.yml +0 -9
- data/test/dummy/test/fixtures/users.yml +0 -11
- data/test/dummy/test/functional/articles_controller_test.rb +0 -49
- data/test/dummy/test/functional/posts_controller_test.rb +0 -49
- data/test/dummy/test/unit/article_test.rb +0 -7
- data/test/dummy/test/unit/helpers/articles_helper_test.rb +0 -4
- data/test/dummy/test/unit/helpers/posts_helper_test.rb +0 -4
- data/test/dummy/test/unit/post_test.rb +0 -7
- data/test/dummy/test/unit/user_test.rb +0 -7
- data/test/fixtures/translation_center/categories.yml +0 -7
- data/test/fixtures/translation_center/translation_keys.yml +0 -11
- data/test/fixtures/translation_center/translations.yml +0 -15
- data/test/functional/translation_center/categories_controller_test.rb +0 -51
- data/test/functional/translation_center/center_controller_test.rb +0 -9
- data/test/functional/translation_center/translation_keys_controller_test.rb +0 -51
- data/test/functional/translation_center/translations_controller_test.rb +0 -51
- data/test/integration/navigation_test.rb +0 -10
- data/test/test_helper.rb +0 -15
- data/test/translation_center_test.rb +0 -7
- data/test/unit/helpers/translation_center/categories_helper_test.rb +0 -6
- data/test/unit/helpers/translation_center/center_helper_test.rb +0 -6
- data/test/unit/helpers/translation_center/translation_keys_helper_test.rb +0 -6
- data/test/unit/helpers/translation_center/translations_helper_test.rb +0 -6
- data/test/unit/translation_center/category_test.rb +0 -9
- data/test/unit/translation_center/translation_key_test.rb +0 -9
- data/test/unit/translation_center/translation_test.rb +0 -9
@@ -0,0 +1,24 @@
|
|
1
|
+
class ActsAsVotableMigration < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :votes do |t|
|
4
|
+
|
5
|
+
t.references :votable, :polymorphic => true
|
6
|
+
t.references :voter, :polymorphic => true
|
7
|
+
|
8
|
+
t.boolean :vote_flag
|
9
|
+
t.string :vote_scope
|
10
|
+
t.integer :vote_weight
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index :votes, [:votable_id, :votable_type]
|
16
|
+
add_index :votes, [:voter_id, :voter_type]
|
17
|
+
add_index :votes, [:voter_id, :voter_type, :vote_scope]
|
18
|
+
add_index :votes, [:votable_id, :votable_type, :vote_scope]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.down
|
22
|
+
drop_table :votes
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class InstallAudited < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :audits, :force => true do |t|
|
4
|
+
t.column :auditable_id, :integer
|
5
|
+
t.column :auditable_type, :string
|
6
|
+
t.column :associated_id, :integer
|
7
|
+
t.column :associated_type, :string
|
8
|
+
t.column :user_id, :integer
|
9
|
+
t.column :user_type, :string
|
10
|
+
t.column :username, :string
|
11
|
+
t.column :action, :string
|
12
|
+
t.column :audited_changes, :text
|
13
|
+
t.column :version, :integer, :default => 0
|
14
|
+
t.column :comment, :string
|
15
|
+
t.column :remote_address, :string
|
16
|
+
t.column :created_at, :datetime
|
17
|
+
end
|
18
|
+
|
19
|
+
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
|
20
|
+
add_index :audits, [:associated_id, :associated_type], :name => 'associated_index'
|
21
|
+
add_index :audits, [:user_id, :user_type], :name => 'user_index'
|
22
|
+
add_index :audits, :created_at
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.down
|
26
|
+
drop_table :audits
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class FixTranslationUserRelation < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
rename_column :translation_center_translations, :user_id, :translator_id
|
4
|
+
add_column :translation_center_translations, :translator_type, :string
|
5
|
+
TranslationCenter::Translation.update_all(translator_type: 'User')
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
rename_column :translation_center_translations, :translator_id, :user_id
|
10
|
+
remove_column :translation_center_translations, :translator_type
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20130801102021) do
|
15
|
+
|
16
|
+
create_table "articles", :force => true do |t|
|
17
|
+
t.string "title"
|
18
|
+
t.text "content"
|
19
|
+
t.datetime "created_at", :null => false
|
20
|
+
t.datetime "updated_at", :null => false
|
21
|
+
end
|
22
|
+
|
23
|
+
create_table "audits", :force => true do |t|
|
24
|
+
t.integer "auditable_id"
|
25
|
+
t.string "auditable_type"
|
26
|
+
t.integer "associated_id"
|
27
|
+
t.string "associated_type"
|
28
|
+
t.integer "user_id"
|
29
|
+
t.string "user_type"
|
30
|
+
t.string "username"
|
31
|
+
t.string "action"
|
32
|
+
t.text "audited_changes"
|
33
|
+
t.integer "version", :default => 0
|
34
|
+
t.string "comment"
|
35
|
+
t.string "remote_address"
|
36
|
+
t.datetime "created_at"
|
37
|
+
end
|
38
|
+
|
39
|
+
add_index "audits", ["associated_id", "associated_type"], :name => "associated_index"
|
40
|
+
add_index "audits", ["auditable_id", "auditable_type"], :name => "auditable_index"
|
41
|
+
add_index "audits", ["created_at"], :name => "index_audits_on_created_at"
|
42
|
+
add_index "audits", ["user_id", "user_type"], :name => "user_index"
|
43
|
+
|
44
|
+
create_table "translation_center_categories", :force => true do |t|
|
45
|
+
t.string "name"
|
46
|
+
t.datetime "created_at", :null => false
|
47
|
+
t.datetime "updated_at", :null => false
|
48
|
+
end
|
49
|
+
|
50
|
+
create_table "translation_center_translation_keys", :force => true do |t|
|
51
|
+
t.string "name"
|
52
|
+
t.integer "category_id"
|
53
|
+
t.datetime "last_accessed"
|
54
|
+
t.string "en_status", :default => "untranslated"
|
55
|
+
t.datetime "created_at", :null => false
|
56
|
+
t.datetime "updated_at", :null => false
|
57
|
+
t.string "de_status", :default => "untranslated"
|
58
|
+
t.string "ar_status", :default => "untranslated"
|
59
|
+
end
|
60
|
+
|
61
|
+
add_index "translation_center_translation_keys", ["name"], :name => "index_translation_center_translation_keys_on_name"
|
62
|
+
|
63
|
+
create_table "translation_center_translations", :force => true do |t|
|
64
|
+
t.integer "translation_key_id"
|
65
|
+
t.string "value"
|
66
|
+
t.string "lang"
|
67
|
+
t.integer "translator_id"
|
68
|
+
t.string "status", :default => "pending"
|
69
|
+
t.datetime "created_at", :null => false
|
70
|
+
t.datetime "updated_at", :null => false
|
71
|
+
t.string "translator_type"
|
72
|
+
end
|
73
|
+
|
74
|
+
add_index "translation_center_translations", ["translation_key_id"], :name => "index_translation_center_translations_on_translation_key_id"
|
75
|
+
|
76
|
+
create_table "users", :force => true do |t|
|
77
|
+
t.string "email", :default => "", :null => false
|
78
|
+
t.string "encrypted_password", :default => "", :null => false
|
79
|
+
t.string "reset_password_token"
|
80
|
+
t.datetime "reset_password_sent_at"
|
81
|
+
t.datetime "remember_created_at"
|
82
|
+
t.integer "sign_in_count", :default => 0
|
83
|
+
t.datetime "current_sign_in_at"
|
84
|
+
t.datetime "last_sign_in_at"
|
85
|
+
t.string "current_sign_in_ip"
|
86
|
+
t.string "last_sign_in_ip"
|
87
|
+
t.datetime "created_at", :null => false
|
88
|
+
t.datetime "updated_at", :null => false
|
89
|
+
end
|
90
|
+
|
91
|
+
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
92
|
+
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
93
|
+
|
94
|
+
create_table "votes", :force => true do |t|
|
95
|
+
t.integer "votable_id"
|
96
|
+
t.string "votable_type"
|
97
|
+
t.integer "voter_id"
|
98
|
+
t.string "voter_type"
|
99
|
+
t.boolean "vote_flag"
|
100
|
+
t.string "vote_scope"
|
101
|
+
t.integer "vote_weight"
|
102
|
+
t.datetime "created_at", :null => false
|
103
|
+
t.datetime "updated_at", :null => false
|
104
|
+
end
|
105
|
+
|
106
|
+
add_index "votes", ["votable_id", "votable_type", "vote_scope"], :name => "index_votes_on_votable_id_and_votable_type_and_vote_scope"
|
107
|
+
add_index "votes", ["votable_id", "votable_type"], :name => "index_votes_on_votable_id_and_votable_type"
|
108
|
+
add_index "votes", ["voter_id", "voter_type", "vote_scope"], :name => "index_votes_on_voter_id_and_voter_type_and_vote_scope"
|
109
|
+
add_index "votes", ["voter_id", "voter_type"], :name => "index_votes_on_voter_id_and_voter_type"
|
110
|
+
|
111
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :vote do
|
3
|
+
# t.integer "votable_id"
|
4
|
+
# t.string "votable_type"
|
5
|
+
# t.integer "voter_id"
|
6
|
+
# t.string "voter_type"
|
7
|
+
# t.boolean "vote_flag"
|
8
|
+
# t.string "vote_scope"
|
9
|
+
# t.integer "vote_weight"
|
10
|
+
# t.datetime "created_at", :null => false
|
11
|
+
# t.datetime "updated_at", :null => false
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'generator_spec'
|
3
|
+
require 'generators/translation_center/add_lang/add_lang_generator'
|
4
|
+
|
5
|
+
module TranslationCenter
|
6
|
+
describe AddLangGenerator do
|
7
|
+
include GeneratorSpec::TestCase
|
8
|
+
destination File.expand_path("../../tmp", __FILE__)
|
9
|
+
arguments %w(fr)
|
10
|
+
|
11
|
+
context "add language" do
|
12
|
+
it "should add a French language" do
|
13
|
+
prepare_destination
|
14
|
+
|
15
|
+
run_generator
|
16
|
+
|
17
|
+
migration_path = "db/migrate/add_fr_status_translation_center_translation_keys.rb"
|
18
|
+
assert_migration migration_path
|
19
|
+
|
20
|
+
# Cleaning up generated migration file
|
21
|
+
FileUtils.rm_rf(Dir[File.expand_path("../../tmp", __FILE__)])
|
22
|
+
assert_no_migration migration_path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module TranslationCenter
|
3
|
+
describe Category do
|
4
|
+
let(:category) { FactoryGirl.create(:category) }
|
5
|
+
let(:translation) { FactoryGirl.create(:translation) }
|
6
|
+
|
7
|
+
it "should return array of keys" do
|
8
|
+
expect(category.all_keys(nil).class.name).to eq 'ActiveRecord::Associations::CollectionProxy'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return name" do
|
12
|
+
expect(category.view_name.class.name).to eq 'String'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return keys that are pended in the language" do
|
16
|
+
pending_keys = category.pending_keys(translation.lang).collect(&:"#{translation.lang}_status").uniq
|
17
|
+
expect(pending_keys.length).to be < 2
|
18
|
+
expect(["pending" , nil]).to include pending_keys.first
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return keys that have no translations in the language" do
|
22
|
+
untranslated = category.untranslated_keys(translation.lang).collect(&:"#{translation.lang}_status").uniq
|
23
|
+
expect(untranslated.length).to be < 2
|
24
|
+
expect(["untranslated" , nil]).to include untranslated.first
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return keys that have translations in the language" do
|
28
|
+
translated_keys = category.accepted_keys(translation.lang).collect(&:"#{translation.lang}_status").uniq
|
29
|
+
expect(translated_keys.length).to be < 2
|
30
|
+
expect(["translated" , nil]).to include translated_keys.first
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return percentage of compeletion" do
|
34
|
+
expect(category.complete_percentage_in(translation.lang).class.name).to eq "Fixnum"
|
35
|
+
FactoryGirl.create(:translation_key, name: "category.new")
|
36
|
+
expect(Category.find(category).complete_percentage_in(translation.lang).class.name).to eq "Fixnum"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TranslationCenter
|
4
|
+
describe TranslationKey do
|
5
|
+
let(:translation_key) { FactoryGirl.create(:translation_key, name: "whatever") }
|
6
|
+
|
7
|
+
let(:en_translation) do
|
8
|
+
FactoryGirl.create(
|
9
|
+
:translation,
|
10
|
+
value: "Whatever",
|
11
|
+
translation_key: translation_key,
|
12
|
+
lang: "en"
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:language) { "en" }
|
17
|
+
|
18
|
+
it "it should create new translation" do
|
19
|
+
expect(translation_key.create_default_translation).to be_truthy
|
20
|
+
end
|
21
|
+
|
22
|
+
it "it should return all languages stats" do
|
23
|
+
expect(TranslationKey.langs_stats.class.name).to eq "Hash"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "it should return nested translations for language" do
|
27
|
+
FactoryGirl.create(:translation_key, name: "whatever.whatever")
|
28
|
+
children = translation_key.children_translations(en_translation)
|
29
|
+
expect(children.class.name).to eq "Hash"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "it should check if there area any nested translations for key" do
|
33
|
+
expect(translation_key.has_children?).to be_falsey
|
34
|
+
FactoryGirl.create(:translation_key, name: "whatever.whatever")
|
35
|
+
expect(translation_key.has_children?).to be_truthy
|
36
|
+
end
|
37
|
+
|
38
|
+
it "it should nested translations for language" do
|
39
|
+
translation_key.update_attributes(name: "whatever.whatever")
|
40
|
+
en_translation.accept
|
41
|
+
expect(translation_key.add_to_hash({}, en_translation.lang).class.name).to eq "Hash"
|
42
|
+
end
|
43
|
+
|
44
|
+
context "counters" do
|
45
|
+
it "it should coutnt all records for translation keys table" do
|
46
|
+
expect(TranslationKey.keys_count.class.name).to eq "Fixnum"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "it should count translated keys for language" do
|
50
|
+
expect(TranslationKey.translated_count(language)).to eq TranslationKey.where(:"#{language}_status" => TranslationKey::TRANSLATED).count
|
51
|
+
end
|
52
|
+
|
53
|
+
it "it should count pending keys for language" do
|
54
|
+
expect(TranslationKey.pending_count(language)).to eq TranslationKey.where(:"#{language}_status" => TranslationKey::PENDING).count
|
55
|
+
end
|
56
|
+
|
57
|
+
it "it should count untranslated keys for language" do
|
58
|
+
expect(TranslationKey.untranslated_count(language)).to eq TranslationKey.where(:"#{language}_status" => TranslationKey::UNTRANSLATED).count
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "percentages calculating" do
|
63
|
+
it "it should calculate percentages for translated keys for language" do
|
64
|
+
expect(TranslationKey.translated_percentage(language).class.name).to eq "Float"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "it should calculate percentages for pending keys for language" do
|
68
|
+
expect(TranslationKey.pending_percentage(language).class.name).to eq "Float"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "it should calculate percentages for untranslated keys for language" do
|
72
|
+
expect(TranslationKey.untranslated_percentage(language).class.name).to eq "Float"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "update status" do
|
77
|
+
it "should update translation key status to translated" do
|
78
|
+
expect(TranslationKey.untranslated(language)).to eq([translation_key])
|
79
|
+
|
80
|
+
en_translation.accept
|
81
|
+
|
82
|
+
expect(TranslationKey.untranslated(language)).to be_empty
|
83
|
+
expect(TranslationKey.translated(language)).to eq([translation_key])
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should update translation key status to pending" do
|
87
|
+
expect(TranslationKey.untranslated(language)).to eq([translation_key])
|
88
|
+
|
89
|
+
en_translation
|
90
|
+
|
91
|
+
expect(TranslationKey.untranslated(language)).to be_empty
|
92
|
+
expect(TranslationKey.pending(language)).to eq([translation_key])
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should update translation key status to untranslated" do
|
96
|
+
translation_key.update_attribute(:"#{language}_status", TranslationKey::UNTRANSLATED)
|
97
|
+
expect(translation_key.status(language)).to eq TranslationKey::UNTRANSLATED
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "status scopes" do
|
102
|
+
it "should return the untranslated English translations" do
|
103
|
+
expect(TranslationKey.untranslated(language)).to eq([translation_key])
|
104
|
+
|
105
|
+
expect(TranslationKey.translated(language)).to eq([])
|
106
|
+
expect(TranslationKey.pending(language)).to eq([])
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should return the pending English translations" do
|
110
|
+
en_translation
|
111
|
+
expect(TranslationKey.pending(language)).to eq([translation_key])
|
112
|
+
|
113
|
+
expect(TranslationKey.untranslated(language)).to eq([])
|
114
|
+
expect(TranslationKey.translated(language)).to eq([])
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should return the translated English translations" do
|
118
|
+
en_translation.accept
|
119
|
+
expect(TranslationKey.translated(language)).to eq([translation_key])
|
120
|
+
|
121
|
+
expect(TranslationKey.untranslated(language)).to eq([])
|
122
|
+
expect(TranslationKey.pending(language)).to eq([])
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "predicates" do
|
127
|
+
it "should be accepted and have translation in English" do
|
128
|
+
en_translation.accept
|
129
|
+
|
130
|
+
expect(translation_key.accepted_in?(language)).to be_truthy
|
131
|
+
expect(translation_key.has_translations_in?(language)).to be_truthy
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should be untranslated in German" do
|
135
|
+
expect(translation_key.no_translations_in?("de")).to be_truthy
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should be pending in English" do
|
139
|
+
en_translation
|
140
|
+
|
141
|
+
expect(translation_key.pending_in?(language)).to be_truthy
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|