air18n 0.1.45 → 0.1.46

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,8 +33,11 @@ module Air18n
33
33
  end
34
34
 
35
35
  def create_row_in_screenshots
36
- if !Screenshot.find_by_screenshot_url(self.screenshot_url)
37
- screenshot = Screenshot.create(:screenshot_url => self.screenshot_url, :status => 0)
36
+ if !Screenshot.where(:screenshot_url => self.screenshot_url).exists?
37
+ Screenshot.create do |s|
38
+ s.screenshot_url = self.screenshot_url
39
+ s.status = 0
40
+ end
38
41
  end
39
42
  end
40
43
 
@@ -79,12 +82,18 @@ module Air18n
79
82
  def self.associate_phrase_with_screenshot(
80
83
  phrase_key, controller_name, action_name, screenshot_url)
81
84
  ps = PhraseScreenshot.find_or_create_by_controller_and_action_and_phrase_key(
82
- controller_name, action_name, phrase_key, :screenshot_url => screenshot_url)
85
+ controller_name, action_name, phrase_key) do |new_phrase_screenshot|
86
+ new_phrase_screenshot.screenshot_url = screenshot_url
87
+ end
83
88
 
84
89
  # If the PhraseScreenshot already existed, update the screenshot URL.
85
90
  if ps.screenshot_url.blank? && ps.screenshot_url != screenshot_url
86
91
  ps.screenshot_url = screenshot_url
87
92
  ps.save
93
+
94
+ # Make sure that this new screenshot URL has a row in the screenshots
95
+ # table.
96
+ ps.create_row_in_screenshots
88
97
  end
89
98
 
90
99
  ps
@@ -1,3 +1,3 @@
1
1
  module Air18n
2
- VERSION = "0.1.45"
2
+ VERSION = "0.1.46"
3
3
  end
@@ -116,7 +116,8 @@ describe Air18n::Backend do
116
116
  @tAf = FactoryGirl.create(:phrase_translation, :phrase => @phraseA, :value => 'French value A', :locale => :fr)
117
117
 
118
118
  @backend.lookup(:es, @phraseA.key).should == 'Spanish value A'
119
- @tAs.update_attributes(:value => 'Updated Spanish value A')
119
+ @tAs.value = 'Updated Spanish value A'
120
+ @tAs.save
120
121
  @backend.lookup(:es, @phraseA.key, [], :default => @phraseA.value).should == 'Spanish value A'
121
122
  @backend.lookup(:fr, @phraseA.key).should == 'French value A'
122
123
  @backend.lookup(:it, @phraseA.key, [], :default => @phraseA.value).should == 'value A'
@@ -129,8 +130,10 @@ describe Air18n::Backend do
129
130
 
130
131
  @backend.lookup(:es, @phraseC.key, [], :default => @phraseC.value).should == 'Spanish value C'
131
132
  @backend.lookup(:fr, @phraseC.key).should == 'French value C'
132
- @tCs.update_attributes(:value => 'Newer Spanish value C')
133
- @tCf.update_attributes(:value => 'Newer French value C')
133
+ @tCs.value = 'Newer Spanish value C'
134
+ @tCs.save
135
+ @tCf.value = 'Newer French value C'
136
+ @tCf.save
134
137
  I18n.mark_translations_as_changed(:es)
135
138
  I18n.mark_translations_as_changed(:fr)
136
139
  @backend.check_for_new_translations(:es)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: air18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.45
4
+ version: 0.1.46
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-12-11 00:00:00.000000000 Z
16
+ date: 2012-12-18 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: i18n