Skip to content
This repository
Browse code

style nazi hits

  • Loading branch information...
commit 2bcc7dfa55719e0b81535ec978187fa3f8e40483 1 parent c4498e7
Sven Fuchs svenfuchs authored

Showing 1 changed file with 28 additions and 26 deletions. Show diff stats Hide diff stats

  1. +28 26 test/active_record_test.rb
54 test/active_record_test.rb
@@ -187,7 +187,7 @@ def assert_translated(locale, record, names, expected)
187 187 assert_equal [], post.changed
188 188 post.subject = 'baz'
189 189 I18n.locale = :de
190   - assert_equal [ 'subject' ], post.changed
  190 + assert_equal ['subject'], post.changed
191 191 end
192 192
193 193 test 'complex writing and stashing' do
@@ -235,7 +235,7 @@ def assert_translated(locale, record, names, expected)
235 235 end
236 236
237 237 test "attribute loading goes by content locale and not global locale" do
238   - post = Post.create :subject => 'foo'
  238 + post = Post.create(:subject => 'foo')
239 239 assert_equal :en, ActiveRecord::Base.locale
240 240 ActiveRecord::Base.locale = :de
241 241 assert_equal :en, I18n.locale
@@ -252,13 +252,13 @@ def assert_translated(locale, record, names, expected)
252 252
253 253 test "available_locales" do
254 254 Post.locale = :de
255   - post = Post.create :subject => 'foo'
  255 + post = Post.create(:subject => 'foo')
256 256 Post.locale = :es
257   - post.update_attribute :subject, 'bar'
  257 + post.update_attribute(:subject, 'bar')
258 258 Post.locale = :fr
259   - post.update_attribute :subject, 'baz'
260   - assert_equal [ :de, :es, :fr ], post.available_locales
261   - assert_equal [ :de, :es, :fr ], Post.first.available_locales
  259 + post.update_attribute(:subject, 'baz')
  260 + assert_equal [:de, :es, :fr], post.available_locales
  261 + assert_equal [:de, :es, :fr], Post.first.available_locales
262 262 end
263 263
264 264 test "saving record correctly after post-save reload" do
@@ -277,8 +277,8 @@ def translations_included
277 277 end
278 278 end
279 279
280   - default = Post.all.map {|x| [x.subject, x.content]}
281   - with_include = Post.translations_included.map {|x| [x.subject, x.content]}
  280 + default = Post.all.map { |x| [x.subject, x.content] }
  281 + with_include = Post.translations_included.map { |x| [x.subject, x.content] }
282 282 assert_equal default, with_include
283 283 end
284 284
@@ -300,11 +300,11 @@ def translations_included
300 300
301 301 test "setting only one translation with set_translations" do
302 302 Post.locale = :de
303   - post = Post.create :subject => "foo1", :content => "foo1"
  303 + post = Post.create(:subject => "foo1", :content => "foo1")
304 304 Post.locale = :en
305   - post.update_attributes( :subject => "bar1", :content => "bar1" )
  305 + post.update_attributes(:subject => "bar1", :content => "bar1")
306 306
307   - options = { :en => {:subject => "bar2", :content => "bar2"} }
  307 + options = { :en => { :subject => "bar2", :content => "bar2" } }
308 308 post.set_translations options
309 309 post.reload
310 310
@@ -315,11 +315,11 @@ def translations_included
315 315
316 316 test "setting only selected attributes with set_translations" do
317 317 Post.locale = :de
318   - post = Post.create :subject => "foo1", :content => "foo1"
  318 + post = Post.create(:subject => "foo1", :content => "foo1")
319 319 Post.locale = :en
320   - post.update_attributes( :subject => "bar1", :content => "bar1" )
  320 + post.update_attributes(:subject => "bar1", :content => "bar1")
321 321
322   - options = { :de => {:content => "foo2"}, :en => {:subject => "bar2"} }
  322 + options = { :de => { :content => "foo2" }, :en => { :subject => "bar2" } }
323 323 post.set_translations options
324 324 post.reload
325 325
@@ -330,9 +330,9 @@ def translations_included
330 330
331 331 test "setting invalid attributes raises ArgumentError" do
332 332 Post.locale = :de
333   - post = Post.create :subject => "foo1", :content => "foo1"
  333 + post = Post.create(:subject => "foo1", :content => "foo1")
334 334 Post.locale = :en
335   - post.update_attributes( :subject => "bar1", :content => "bar1" )
  335 + post.update_attributes(:subject => "bar1", :content => "bar1")
336 336
337 337 options = { :de => {:fake => "foo2"} }
338 338 exception = assert_raise(ActiveRecord::UnknownAttributeError) do
@@ -342,13 +342,13 @@ def translations_included
342 342 end
343 343
344 344 test "reload accepting find options" do
345   - p = Post.create :subject => "Foo", :content => "Bar"
  345 + p = Post.create(:subject => "Foo", :content => "Bar")
346 346 assert p.reload(:readonly => true, :lock => true)
347 347 assert_raise(ArgumentError) { p.reload(:foo => :bar) }
348 348 end
349 349
350 350 test "dependent destroy of translation" do
351   - p = Post.create :subject => "Foo", :content => "Bar"
  351 + p = Post.create(:subject => "Foo", :content => "Bar")
352 352 assert_equal 1, PostTranslation.count
353 353 p.destroy
354 354 assert_equal 0, PostTranslation.count
@@ -376,10 +376,12 @@ def translations_included
376 376 end
377 377
378 378 test "can create a proxy class for a namespaced model" do
379   - module Foo
380   - module Bar
381   - class Baz < ActiveRecord::Base
382   - translates :bumm
  379 + assert_nothing_raised do
  380 + module Foo
  381 + module Bar
  382 + class Baz < ActiveRecord::Base
  383 + translates :bumm
  384 + end
383 385 end
384 386 end
385 387 end
@@ -387,15 +389,15 @@ class Baz < ActiveRecord::Base
387 389
388 390 test "attribute translated before type cast" do
389 391 Post.locale = :en
390   - post = Post.create :subject => 'foo', :content => 'bar'
  392 + post = Post.create(:subject => 'foo', :content => 'bar')
391 393 Post.locale = :de
392   - post.update_attribute :subject, "German foo"
  394 + post.update_attribute(:subject, "German foo")
393 395 assert_equal 'German foo', post.subject_before_type_cast
394 396 Post.locale = :en
395 397 assert_equal 'foo', post.subject_before_type_cast
396 398 end
397 399
398   - test "don't override existing translation model" do
  400 + test "don't override existing translation class" do
399 401 assert PostTranslation.new.respond_to?(:existing_method)
400 402 end
401 403 end

0 comments on commit 2bcc7df

Please sign in to comment.
Something went wrong with that request. Please try again.