exvo_globalize 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module ExvoGlobalize
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
@@ -21,9 +21,21 @@ module ExvoGlobalize
21
21
  end
22
22
  end
23
23
 
24
+ # Migrates template or skips if it already exists
25
+ # see https://github.com/rails/rails/blob/master/railties/lib/rails/generators/migration.rb#L55
26
+ def self.migrate_template_or_skip(source, destination)
27
+ migration_dir = File.dirname(destination)
28
+
29
+ migration_file_name = File.basename(destination).sub(/\.rb$/, '')
30
+ unless migration_exists?(migration_dir, migration_file_name)
31
+ migration_template(source, destination)
32
+ end
33
+ end
34
+
24
35
  desc "Add a 'create_globalize_translations' migration"
25
36
  def create_migration_file
26
- migration_template 'migration.rb', 'db/migrate/create_globalize_translations.rb'
37
+ self.class.migrate_template_or_skip 'migration.rb', 'db/migrate/create_globalize_translations.rb'
38
+ self.class.migrate_template_or_skip 'suggestions_migration.rb', 'db/migrate/create_globalize_translation_suggestions.rb'
27
39
  end
28
40
 
29
41
  if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR == 0
@@ -33,5 +45,4 @@ module ExvoGlobalize
33
45
  end
34
46
  end
35
47
  end
36
-
37
- end
48
+ end
@@ -0,0 +1,16 @@
1
+ class CreateGlobalizeTranslationSuggestions < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :globalize_translation_suggestions do |t|
4
+ t.string :key
5
+ t.text :value
6
+ t.integer :votes, :default => 1
7
+ t.timestamps
8
+
9
+ t.references :globalize_translations
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :globalize_translation_suggestions
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ namespace :globalize do
2
+ desc "Update Exvo Globalize"
3
+ task :update do
4
+ `rails g exvo_globalize:install`
5
+ end
6
+ end
data/spec/app.rb CHANGED
@@ -38,5 +38,15 @@ class CreateGlobalizeTranslations < ActiveRecord::Migration
38
38
  t.boolean :is_proc, :default => false
39
39
  t.timestamps
40
40
  end
41
+
42
+ create_table :globalize_translation_suggestions do |t|
43
+ t.string :locale
44
+ t.string :key
45
+ t.text :value
46
+ t.integer :votes, :default => 1
47
+ t.timestamps
48
+
49
+ t.references :globalize_translation
50
+ end
41
51
  end
42
- end
52
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe GlobalizeTranslationSuggestionsController do
4
+
5
+ render_views
6
+ let(:page) { Capybara::Node::Simple.new(@response.body) }
7
+
8
+ context "Feedback" do
9
+
10
+ describe "GET :feedback" do
11
+ before do
12
+ get :feedback, :locale => 'pt'
13
+ end
14
+
15
+ it "returns a array with translations" do
16
+ assigns(:translations).should be_a(Array)
17
+ end
18
+ end
19
+
20
+ describe "POST :send_feedback" do
21
+ let(:suggestion) { Factory(:i18n_suggestion) }
22
+
23
+ before do
24
+ @globalize_translation = suggestion.globalize_translation
25
+ post :send_feedback, :globalize_translation_id => @globalize_translation.id, :body => 'Some suggestion'
26
+ end
27
+
28
+ it { should respond_with(:success) }
29
+
30
+ it "should add votes to a suggestion" do
31
+ globalize_suggestion = GlobalizeTranslationSuggestion.where(:value => 'Some suggestion').first
32
+ post :send_feedback, :globalize_translation_id => @globalize_translation.id, :body => 'Some suggestion'
33
+
34
+ globalize_suggestion.reload.votes.should == 2
35
+ end
36
+
37
+ it "should add votes to a suggestion by passing the suggestion id" do
38
+ globalize_suggestion = GlobalizeTranslationSuggestion.where(:value => 'Some suggestion').first
39
+
40
+ post :send_feedback, :globalize_translation_id => @globalize_translation.id, :globalize_translation_suggestion_id => globalize_suggestion.id
41
+ globalize_suggestion.reload.votes.should == 2
42
+ end
43
+ end
44
+ end
45
+ end
data/spec/factories.rb CHANGED
@@ -23,3 +23,14 @@ Factory.define :i18n_title_pl, :class => GlobalizeTranslation do |u|
23
23
  u.key 'title'
24
24
  u.value 'To jest tytuł'
25
25
  end
26
+
27
+ Factory.define :i18n_feedback, :class => GlobalizeTranslation do |u|
28
+ u.locale 'pt'
29
+ u.key 'title'
30
+ u.value 'Isso é um titulo'
31
+ end
32
+
33
+ Factory.define :i18n_suggestion, :class => GlobalizeTranslationSuggestion do |u|
34
+ u.value "Isto é um titulo"
35
+ u.association :globalize_translation, :factory => :i18n_feedback
36
+ end
@@ -20,5 +20,4 @@ describe GlobalizeTranslation do
20
20
  it "lists available locales" do
21
21
  [i18n_title, i18n_title_pl].map(&:locale).map(&:to_sym).should =~ GlobalizeTranslation.available_locales
22
22
  end
23
-
24
- end
23
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe GlobalizeTranslationSuggestion do
5
+
6
+ let(:i18n_suggestion) { Factory(:i18n_suggestion) }
7
+
8
+ it "has a votes count" do
9
+ i18n_suggestion.votes.should eql(1)
10
+ end
11
+
12
+ it "should have a text" do
13
+ suggestion = GlobalizeTranslationSuggestion.new(:globalize_translation => i18n_suggestion.globalize_translation)
14
+ suggestion.valid?.should be_false
15
+ suggestion.errors[:value].should eql(["can't be blank"])
16
+ end
17
+
18
+ it "should overwrite the parent translation when the number of votes is bigger than 'ExvoGlobalize.feedback_votes_count' which defaults to 40" do
19
+ i18n_suggestion.update_attributes(:votes => 40)
20
+ i18n_suggestion.globalize_translation.reload.value.should eql("Isto é um titulo")
21
+ end
22
+
23
+ it "should overwrite the parent translation by setting the required number of votes" do
24
+ ExvoGlobalize.feedback_votes_count = 10
25
+ i18n_suggestion.update_attributes(:votes => 11)
26
+ i18n_suggestion.globalize_translation.reload.value.should eql("Isto é um titulo")
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exvo_globalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-23 00:00:00.000000000Z
12
+ date: 2011-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &79639940 !ruby/object:Gem::Requirement
16
+ requirement: &70173068218440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *79639940
24
+ version_requirements: *70173068218440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &79639680 !ruby/object:Gem::Requirement
27
+ requirement: &70173068217920 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.5'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *79639680
35
+ version_requirements: *70173068217920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: haml
38
- requirement: &79639490 !ruby/object:Gem::Requirement
38
+ requirement: &70173068217520 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *79639490
46
+ version_requirements: *70173068217520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: awesome_print
49
- requirement: &79639260 !ruby/object:Gem::Requirement
49
+ requirement: &70173068217060 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *79639260
57
+ version_requirements: *70173068217060
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: ya2yaml
60
- requirement: &79639050 !ruby/object:Gem::Requirement
60
+ requirement: &70173068216620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *79639050
68
+ version_requirements: *70173068216620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: httparty
71
- requirement: &79638840 !ruby/object:Gem::Requirement
71
+ requirement: &70173068216200 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *79638840
79
+ version_requirements: *70173068216200
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sqlite3
82
- requirement: &79638600 !ruby/object:Gem::Requirement
82
+ requirement: &70173068215780 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *79638600
90
+ version_requirements: *70173068215780
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &79638300 !ruby/object:Gem::Requirement
93
+ requirement: &70173068215260 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '2.6'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *79638300
101
+ version_requirements: *70173068215260
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rspec-rails
104
- requirement: &79638060 !ruby/object:Gem::Requirement
104
+ requirement: &70173068214840 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *79638060
112
+ version_requirements: *70173068214840
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: factory_girl_rails
115
- requirement: &79637730 !ruby/object:Gem::Requirement
115
+ requirement: &70173068214380 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *79637730
123
+ version_requirements: *70173068214380
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: shoulda-matchers
126
- requirement: &79637210 !ruby/object:Gem::Requirement
126
+ requirement: &70173068213960 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *79637210
134
+ version_requirements: *70173068213960
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: capybara
137
- requirement: &79637000 !ruby/object:Gem::Requirement
137
+ requirement: &70173068213540 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *79637000
145
+ version_requirements: *70173068213540
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: json
148
- requirement: &79636790 !ruby/object:Gem::Requirement
148
+ requirement: &70173068213120 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *79636790
156
+ version_requirements: *70173068213120
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: jasmine-headless-webkit
159
- requirement: &79636410 !ruby/object:Gem::Requirement
159
+ requirement: &70173068212600 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: 0.7.3.2
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *79636410
167
+ version_requirements: *70173068212600
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: therubyracer
170
- requirement: &79636090 !ruby/object:Gem::Requirement
170
+ requirement: &70173068212180 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ! '>='
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: '0'
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *79636090
178
+ version_requirements: *70173068212180
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: guard
181
- requirement: &79635680 !ruby/object:Gem::Requirement
181
+ requirement: &70173068211620 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ~>
@@ -186,10 +186,10 @@ dependencies:
186
186
  version: '0.8'
187
187
  type: :development
188
188
  prerelease: false
189
- version_requirements: *79635680
189
+ version_requirements: *70173068211620
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: guard-rspec
192
- requirement: &79635360 !ruby/object:Gem::Requirement
192
+ requirement: &70173068211200 !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
195
195
  - - ! '>='
@@ -197,10 +197,10 @@ dependencies:
197
197
  version: '0'
198
198
  type: :development
199
199
  prerelease: false
200
- version_requirements: *79635360
200
+ version_requirements: *70173068211200
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: guard-jasmine-headless-webkit
203
- requirement: &79635000 !ruby/object:Gem::Requirement
203
+ requirement: &70173068210640 !ruby/object:Gem::Requirement
204
204
  none: false
205
205
  requirements:
206
206
  - - ~>
@@ -208,10 +208,10 @@ dependencies:
208
208
  version: '0.3'
209
209
  type: :development
210
210
  prerelease: false
211
- version_requirements: *79635000
211
+ version_requirements: *70173068210640
212
212
  - !ruby/object:Gem::Dependency
213
213
  name: rb-fsevent
214
- requirement: &79634790 !ruby/object:Gem::Requirement
214
+ requirement: &70173068210220 !ruby/object:Gem::Requirement
215
215
  none: false
216
216
  requirements:
217
217
  - - ! '>='
@@ -219,10 +219,10 @@ dependencies:
219
219
  version: '0'
220
220
  type: :development
221
221
  prerelease: false
222
- version_requirements: *79634790
222
+ version_requirements: *70173068210220
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: rb-inotify
225
- requirement: &79634540 !ruby/object:Gem::Requirement
225
+ requirement: &70173068209760 !ruby/object:Gem::Requirement
226
226
  none: false
227
227
  requirements:
228
228
  - - ! '>='
@@ -230,7 +230,7 @@ dependencies:
230
230
  version: '0'
231
231
  type: :development
232
232
  prerelease: false
233
- version_requirements: *79634540
233
+ version_requirements: *70173068209760
234
234
  description: It exposes `/globalize/translations.json` with JSON of all translations
235
235
  in the app
236
236
  email:
@@ -245,14 +245,25 @@ files:
245
245
  - MIT-LICENSE
246
246
  - README.md
247
247
  - Rakefile
248
+ - app/assets/javascripts/exvo_feedback.js
248
249
  - app/assets/javascripts/exvo_globalize_i18n.js
250
+ - app/assets/javascripts/exvo_rails_ujs.js
251
+ - app/assets/javascripts/jquery.cookie.js
252
+ - app/assets/stylesheets/exvo_globalize.sass
253
+ - app/assets/stylesheets/ie.sass
254
+ - app/controllers/globalize_translation_suggestions_controller.rb
249
255
  - app/controllers/globalize_translations_controller.rb
256
+ - app/helpers/globalize_helper.rb
250
257
  - app/models/globalize_translation.rb
258
+ - app/models/globalize_translation_suggestion.rb
259
+ - app/views/globalize_translation_suggestions/_globalize_translation.html.haml
260
+ - app/views/globalize_translation_suggestions/feedback.html.haml
251
261
  - app/views/globalize_translations/_flash_messages.html.haml
252
262
  - app/views/globalize_translations/list.html.haml
253
263
  - app/views/globalize_translations/show.html.haml
254
264
  - app/views/globalize_translations/show.js.erb
255
265
  - app/views/layouts/exvo_globalize.html.haml
266
+ - app/views/layouts/globalize_feedback.html.haml
256
267
  - config/locales/ar.yml
257
268
  - config/locales/bg.yml
258
269
  - config/locales/bs.yml
@@ -316,11 +327,15 @@ files:
316
327
  - lib/exvo_globalize/engine.rb
317
328
  - lib/exvo_globalize/globalize_app.rb
318
329
  - lib/exvo_globalize/helpers.rb
330
+ - lib/exvo_globalize/plural_examples.rb
319
331
  - lib/exvo_globalize/version.rb
320
332
  - lib/generators/exvo_globalize/install_generator.rb
321
333
  - lib/generators/exvo_globalize/templates/migration.rb
334
+ - lib/generators/exvo_globalize/templates/suggestions_migration.rb
322
335
  - lib/tasks/dump.rake
336
+ - lib/tasks/update.rake
323
337
  - spec/app.rb
338
+ - spec/controllers/globalize_translation_suggestions_spec.rb
324
339
  - spec/controllers/globalize_translations_controller_spec.rb
325
340
  - spec/exvo_globalize/caching_spec.rb
326
341
  - spec/exvo_globalize/fallback_spec.rb
@@ -334,6 +349,7 @@ files:
334
349
  - spec/javascripts/fixtures/translations.js
335
350
  - spec/javascripts/support/jasmine.yml
336
351
  - spec/models/globalize_translation_spec.rb
352
+ - spec/models/globalize_translation_suggestions_spec.rb
337
353
  - spec/spec_helper.rb
338
354
  homepage: https://github.com/Exvo/exvo_globalize
339
355
  licenses:
@@ -356,9 +372,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
356
372
  version: '0'
357
373
  requirements: []
358
374
  rubyforge_project:
359
- rubygems_version: 1.8.10
375
+ rubygems_version: 1.8.6
360
376
  signing_key:
361
377
  specification_version: 3
362
378
  summary: Rails gem to translate your app into multiple languages using Globalize web
363
379
  app
364
- test_files: []
380
+ test_files:
381
+ - spec/app.rb
382
+ - spec/controllers/globalize_translation_suggestions_spec.rb
383
+ - spec/controllers/globalize_translations_controller_spec.rb
384
+ - spec/exvo_globalize/caching_spec.rb
385
+ - spec/exvo_globalize/fallback_spec.rb
386
+ - spec/exvo_globalize/flatten_spec.rb
387
+ - spec/exvo_globalize/globalize_store_spec.rb
388
+ - spec/exvo_globalize/pluralizations_spec.rb
389
+ - spec/factories.rb
390
+ - spec/fixtures/locales/en.yml
391
+ - spec/fixtures/locales/pl.yml
392
+ - spec/javascripts/exvo_globalize_i18n_spec.js
393
+ - spec/javascripts/fixtures/translations.js
394
+ - spec/javascripts/support/jasmine.yml
395
+ - spec/models/globalize_translation_spec.rb
396
+ - spec/models/globalize_translation_suggestions_spec.rb
397
+ - spec/spec_helper.rb