copycat 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +6 -0
  3. data/app/models/copycat_translation.rb +37 -45
  4. data/lib/copycat/version.rb +1 -1
  5. data/spec/dummy/config/application.rb +2 -0
  6. data/spec/dummy/config/initializers/copycat.rb +2 -2
  7. data/spec/dummy/db/development.sqlite3 +0 -0
  8. data/spec/dummy/db/migrate/{20120320194234_create_copycat_translations.copycat_engine.rb → 20150824125132_create_copycat_translations.copycat_engine.rb} +0 -0
  9. data/spec/dummy/db/schema.rb +1 -1
  10. data/spec/dummy/db/test.sqlite3 +0 -0
  11. data/spec/dummy/log/development.log +18 -2052
  12. data/spec/dummy/log/test.log +841 -27512
  13. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/5pjjE7UQ1zT-W3Rm7l8onDEWZV9b-lyRmeW9nFAbLoU.cache +2 -0
  14. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/9ZnyF5L7jalLFn0sk_WNwUCeeXBylJBp2yRgFPQE3ho.cache +1 -0
  15. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/IfC1KmXTw1ppvrXEYn3N4C2stMo3ing1GipxNQ0oML4.cache +0 -0
  16. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/YQfOnucF3bHs51e6OOpX6Gh8ih98sfqcSc88X90cxYg.cache +1 -0
  17. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/bUaVNTYJb9Cp-33TI2vIHrdmO8U0fOh3szyB6M4K7BY.cache +3 -0
  18. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/j2gYDVPsuXlIFLdHtvLu9pJtjz2Z1dmLFVDQp9jNEwc.cache +0 -0
  19. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/qGrLWZnG1ElHmKVImQl1l5olVVtVeDSZ13_9Ll1qeYU.cache +1 -0
  20. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/zQEVaz1UlfTQQY8e-XT2PRLny8dybtFJeuDtPTwwS2E.cache +1 -0
  21. data/spec/factories/copycat_translations.rb +3 -3
  22. data/spec/{integration → features}/copycat_spec.rb +78 -78
  23. data/spec/features/dummy_spec.rb +92 -0
  24. data/spec/lib/copycat_spec.rb +5 -5
  25. data/spec/models/copycat_translation_spec.rb +50 -69
  26. data/spec/spec_helper.rb +5 -2
  27. data/spec/support/export.yml +10 -0
  28. metadata +143 -47
  29. data/spec/dummy/tmp/cache/assets/C19/060/sprockets%2F125436f53217b7f564aa5016d1168709 +0 -0
  30. data/spec/dummy/tmp/cache/assets/CB3/6E0/sprockets%2F0f4c96b04436bf7ae900561753947d4c +0 -0
  31. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  32. data/spec/dummy/tmp/cache/assets/D09/190/sprockets%2Fb2bddd007999a56d8b20c92301ea1983 +0 -0
  33. data/spec/dummy/tmp/cache/assets/D1A/DB0/sprockets%2F26d700197b8d25f954d56d8f31f2c8bc +0 -0
  34. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  35. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  36. data/spec/dummy/tmp/cache/assets/DA4/EE0/sprockets%2Fcd39e3d56788faea331e0f5bac67329b +0 -0
  37. data/spec/dummy/tmp/cache/assets/DBD/220/sprockets%2F0cbff5c1a349439c1c444cbb4a57acc4 +0 -0
  38. data/spec/dummy/tmp/cache/assets/DDD/780/sprockets%2Fe7880b84c3ecb507fabc99b9ef6b70e3 +0 -0
  39. data/spec/dummy/tmp/cache/assets/DF8/310/sprockets%2Fccb12c4009c2f876d51dee8bae4c64ec +0 -0
  40. data/spec/integration/dummy_spec.rb +0 -92
@@ -1,92 +0,0 @@
1
- #encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- feature "use #t" do
6
-
7
- it "the dummy app has a translation for site.index.header but not site.index.intro" do
8
- I18n.t('site.index.header').should == 'The Header'
9
- I18n.t('site.index.intro').should == "translation missing: en.site.index.intro"
10
- end
11
-
12
- it "uses i18n.t" do
13
- visit root_path
14
- page.should have_content 'The Header'
15
- page.should have_content 'Intro' #ActionView::Helpers::TranslationHelper#translate wrapper
16
- end
17
-
18
- it "creates a copycat_translation if the yaml has an entry" do
19
- CopycatTranslation.find_by_key('site.index.header').should be_nil
20
- visit root_path
21
- CopycatTranslation.find_by_key('site.index.header').should_not be_nil
22
- end
23
-
24
- it "creates a copycat_translation if the yaml does not have an entry" do
25
- CopycatTranslation.find_by_key('site.index.intro').should be_nil
26
- visit root_path
27
- CopycatTranslation.find_by_key('site.index.intro').should_not be_nil
28
- end
29
-
30
- it "shows the copycat_translation instead of the yaml" do
31
- FactoryGirl.create(:copycat_translation, key: 'site.index.header', value: 'A different header')
32
- visit root_path
33
- page.should_not have_content 'The Header'
34
- page.should have_content 'A different header'
35
- end
36
-
37
- end
38
-
39
- feature "locales" do
40
-
41
- it "displays different text based on users' locale" do
42
- FactoryGirl.create(:copycat_translation, locale: 'en', key: 'site.index.intro', value: 'world')
43
- FactoryGirl.create(:copycat_translation, locale: 'es', key: 'site.index.intro', value: 'mundo')
44
-
45
- I18n.locale = :en
46
- visit root_path
47
- page.should have_content 'world'
48
- page.should_not have_content 'mundo'
49
-
50
- I18n.locale = :es
51
- visit root_path
52
- page.should have_content 'mundo'
53
- page.should_not have_content 'world'
54
-
55
- I18n.locale = :fa
56
- visit root_path
57
- page.should_not have_content 'world'
58
- page.should_not have_content 'mundo'
59
-
60
- I18n.locale = :en # reset
61
- end
62
-
63
- end
64
-
65
- feature "yaml" do
66
-
67
- it "round-trips both translations correctly (and doesn't export nils)" do
68
- visit root_path
69
- CopycatTranslation.find_by_key('site.index.intro').value.should be_nil
70
- CopycatTranslation.find_by_key('site.index.header').value.should == 'The Header'
71
- CopycatTranslation.count.should == 2
72
-
73
- page.driver.browser.basic_authorize Copycat.username, Copycat.password
74
- visit import_export_copycat_translations_path
75
- click_link 'Download as YAML'
76
- CopycatTranslation.destroy_all
77
- CopycatTranslation.count.should == 0
78
- yaml = page.text
79
- file = Tempfile.new 'copycat'
80
- file.write yaml
81
- file.close
82
- visit import_export_copycat_translations_path
83
- attach_file "file", file.path
84
- click_button "Upload"
85
- file.unlink
86
-
87
- CopycatTranslation.count.should == 1
88
- CopycatTranslation.find_by_key('site.index.intro').should be_nil
89
- CopycatTranslation.find_by_key('site.index.header').value.should == 'The Header'
90
- end
91
-
92
- end