phrasing 3.2.10 → 4.0.0rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -11
  3. data/CHANGELOG.md +0 -20
  4. data/Gemfile +4 -1
  5. data/README-3.md +134 -0
  6. data/README.md +10 -14
  7. data/Release_notes_version_4.md +26 -0
  8. data/app/assets/javascripts/phrasing.js.erb +37 -17
  9. data/app/assets/stylesheets/phrasing_edit_mode_bubble.css.scss +3 -3
  10. data/app/controllers/phrasing_phrase_versions_controller.rb +4 -4
  11. data/app/controllers/phrasing_phrases_controller.rb +42 -75
  12. data/app/helpers/inline_helper.rb +24 -31
  13. data/app/models/phrasing_phrase.rb +29 -23
  14. data/app/views/phrasing/_production_warning.html.haml +0 -2
  15. data/app/views/phrasing_phrases/edit.html.haml +2 -2
  16. data/app/views/phrasing_phrases/import_export.html.haml +0 -5
  17. data/config/routes.rb +11 -9
  18. data/lib/generators/phrasing/phrasing_generator.rb +26 -0
  19. data/lib/generators/phrasing/templates/app/helpers/phrasing_helper.rb +12 -0
  20. data/lib/generators/phrasing/templates/config/initializers/phrasing.rb +11 -0
  21. data/{db/migrate/20131010101010_create_phrasing_phrase_versions.rb → lib/generators/phrasing/templates/db/migrate/create_phrasing_phrase_versions.rb} +2 -2
  22. data/{db/migrate/20120313191745_create_phrasing_phrases.rb → lib/generators/phrasing/templates/db/migrate/create_phrasing_phrases.rb} +2 -2
  23. data/lib/phrasing.rb +11 -37
  24. data/lib/phrasing/version.rb +2 -2
  25. data/phrasing.gemspec +1 -3
  26. data/spec/features/dummy_spec.rb +27 -24
  27. data/spec/features/phrasing_spec.rb +128 -84
  28. data/spec/lib/phrasing_spec.rb +50 -50
  29. metadata +14 -26
  30. data/4.0.0_changes.md +0 -1
  31. data/lib/phrasing/implementation.rb +0 -21
  32. data/lib/phrasing/simple.rb +0 -3
  33. data/lib/tasks/phrasing_tasks.rake +0 -69
@@ -1,10 +1,10 @@
1
1
  class CreatePhrasingPhrases < ActiveRecord::Migration
2
2
  def change
3
- create_table :phrasing_phrases do |t|
3
+ create_table :phrasing_phrases do |t|
4
4
  t.string :locale
5
5
  t.string :key
6
6
  t.text :value
7
7
  t.timestamps
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -1,10 +1,8 @@
1
1
  require 'phrasing'
2
- require "phrasing/implementation"
3
- require "phrasing/simple"
4
2
  require "phrasing/serializer"
5
3
  require 'jquery-rails'
6
4
  require 'jquery-cookie-rails'
7
- require 'haml'
5
+ require 'haml-rails'
8
6
 
9
7
  module Phrasing
10
8
  module Rails
@@ -12,7 +10,15 @@ module Phrasing
12
10
  initializer :assets, group: :all do
13
11
  ::Rails.application.config.assets.paths << ::Rails.root.join('app', 'assets', 'fonts')
14
12
  ::Rails.application.config.assets.paths << ::Rails.root.join('app', 'assets', 'images')
15
- ::Rails.application.config.assets.precompile += ['editor.js', 'phrasing_engine.css', 'phrasing_engine.js', 'icomoon.dev.svg', 'icomoon.svg', 'icomoon.eot', 'icomoon.ttf', 'icomoon.woff', 'phrasing_icon_edit_all.png']
13
+ ::Rails.application.config.assets.precompile += %w(editor.js
14
+ phrasing_engine.css
15
+ phrasing_engine.js
16
+ icomoon.dev.svg
17
+ icomoon.svg
18
+ icomoon.eot
19
+ icomoon.ttf
20
+ icomoon.woff
21
+ phrasing_icon_edit_all.png)
16
22
  end
17
23
  end
18
24
  end
@@ -23,21 +29,9 @@ module Phrasing
23
29
 
24
30
  mattr_accessor :allow_update_on_all_models_and_attributes
25
31
  mattr_accessor :route
26
- mattr_accessor :staging_server_endpoint
27
- mattr_accessor :parent_controller
28
32
 
29
- @@parent_controller = "ApplicationController"
30
33
  @@route = 'phrasing'
31
34
 
32
- def self.log
33
- @@log
34
- end
35
-
36
- def self.log=(log_value)
37
- @@log = log_value
38
- suppress_log if log_value == false
39
- end
40
-
41
35
  def self.setup
42
36
  yield self
43
37
  end
@@ -59,24 +53,4 @@ module Phrasing
59
53
  def self.is_whitelisted?(klass,attribute)
60
54
  allow_update_on_all_models_and_attributes == true or whitelist.include? "#{klass}.#{attribute}"
61
55
  end
62
-
63
- private
64
-
65
- def self.suppress_log
66
- logger_class = defined?(ActiveSupport::Logger) ? ActiveSupport::Logger::SimpleFormatter : Logger::SimpleFormatter
67
-
68
- logger_class.class_eval do
69
-
70
- alias_method :old_call, :call
71
-
72
- def call(severity, timestamp, progname, msg)
73
- unless (msg.include? "SELECT" and (msg.include? "phrasing_phrases" or msg.include? "phrasing_phrase_versions"))
74
- old_call(severity, timestamp, progname, msg)
75
- end
76
- end
77
-
78
- end
79
- end
80
-
81
-
82
- end
56
+ end
@@ -1,3 +1,3 @@
1
1
  module Phrasing
2
- VERSION = "3.2.10"
3
- end
2
+ VERSION = "4.0.0rc1"
3
+ end
@@ -18,10 +18,8 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_dependency "rails", ">= 3.2.0"
20
20
  s.add_dependency "railties", ">= 3.2"
21
- s.add_dependency "haml"
21
+ s.add_dependency "haml-rails"
22
22
  s.add_dependency "jquery-rails"
23
23
  s.add_dependency "jquery-cookie-rails"
24
24
  s.add_dependency "sass"
25
-
26
- s.add_development_dependency 'pry'
27
25
  end
@@ -5,47 +5,47 @@ feature "use #phrase" do
5
5
 
6
6
  it "should see the header phrase" do
7
7
  visit root_path
8
- page.should have_content 'The Header'
8
+ expect(page).to have_content('The Header')
9
9
  end
10
10
 
11
11
  it "should see the header phrase modified if created before visiting" do
12
12
  FactoryGirl.create(:phrasing_phrase, key: 'site.index.header', value: 'The Header1')
13
13
  visit root_path
14
- page.should have_content 'The Header1'
14
+ expect(page).to have_content 'The Header1'
15
15
  end
16
16
 
17
17
  it "creates a phrasing_phrase if the yaml has an entry" do
18
- PhrasingPhrase.find_by_key('site.index.header').should be_nil
18
+ expect(PhrasingPhrase.find_by_key('site.index.header')).to be_nil
19
19
  visit root_path
20
- PhrasingPhrase.find_by_key('site.index.header').should_not be_nil
20
+ expect(PhrasingPhrase.find_by_key('site.index.header')).not_to be_nil
21
21
  end
22
22
 
23
23
  it "creates a phrasing_phrase if the yaml does not have an entry" do
24
- PhrasingPhrase.find_by_key('site.index.intro').should be_nil
24
+ expect(PhrasingPhrase.find_by_key('site.index.intro')).to be_nil
25
25
  visit root_path
26
- PhrasingPhrase.find_by_key('site.index.intro').should_not be_nil
26
+ expect(PhrasingPhrase.find_by_key('site.index.intro')).not_to be_nil
27
27
  end
28
28
 
29
29
  it "shows the phrasing_phrase instead of the yaml" do
30
30
  FactoryGirl.create(:phrasing_phrase, key: 'site.index.header', value: 'A different header')
31
31
  visit root_path
32
- page.should_not have_content 'The Header'
33
- page.should have_content 'A different header'
32
+ expect(page).not_to have_content 'The Header'
33
+ expect(page).to have_content 'A different header'
34
34
  end
35
35
 
36
36
  it "allows to treat every translation as html safe" do
37
37
  FactoryGirl.create(:phrasing_phrase, key: 'site.index.header', value: '<strong>Strong header</strong>')
38
38
  visit root_path
39
- page.should have_content 'Strong header'
39
+ expect(page).to have_content 'Strong header'
40
40
  visit root_path
41
- page.should_not have_content '<strong>Strong header</strong>'
42
- page.should have_content 'Strong header'
41
+ expect(page).not_to have_content '<strong>Strong header</strong>'
42
+ expect(page).to have_content 'Strong header'
43
43
  end
44
44
 
45
45
  it 'allows to use scope like I18n' do
46
46
  visit root_path
47
- page.should have_content 'models.errors.test'
48
- page.should have_content 'site.test'
47
+ expect(page).to have_content 'models.errors.test'
48
+ expect(page).to have_content 'site.test'
49
49
  end
50
50
  end
51
51
 
@@ -57,18 +57,18 @@ feature "locales" do
57
57
 
58
58
  I18n.locale = :en
59
59
  visit root_path
60
- page.should have_content 'world'
61
- page.should_not have_content 'mundo'
60
+ expect(page).to have_content 'world'
61
+ expect(page).not_to have_content 'mundo'
62
62
 
63
63
  I18n.locale = :es
64
64
  visit root_path
65
- page.should have_content 'mundo'
66
- page.should_not have_content 'world'
65
+ expect(page).to have_content 'mundo'
66
+ expect(page).not_to have_content 'world'
67
67
 
68
68
  I18n.locale = :fa
69
69
  visit root_path
70
- page.should_not have_content 'world'
71
- page.should_not have_content 'mundo'
70
+ expect(page).not_to have_content 'world'
71
+ expect(page).not_to have_content 'mundo'
72
72
 
73
73
  I18n.locale = :en # reset
74
74
  end
@@ -77,18 +77,21 @@ end
77
77
 
78
78
  feature "yaml" do
79
79
 
80
- describe 'on first visit value should be' do
80
+ describe 'on first visit' do
81
81
 
82
- it "same as keys if there is no translation available" do
82
+ it "value should be the same as keys if there is no translation available" do
83
83
  visit root_path
84
- PhrasingPhrase.find_by_key('site.index.intro').value.should == 'site.index.intro'
84
+ expect(PhrasingPhrase.find_by_key('site.index.intro').value).to eq('site.index.intro')
85
85
  end
86
86
 
87
87
  it "same as translations in the yaml file if there is a translation available" do
88
88
  visit root_path
89
- PhrasingPhrase.find_by_key('site.index.header').value.should == 'The Header'
90
- PhrasingPhrase.find_by_key('site.index.footer').value.should == 'The Footer'
89
+ expect(PhrasingPhrase.find_by_key('site.index.header').value).to eq('The Header')
91
90
  end
92
91
 
92
+ it "if using I18n.t(), there shouldn't be a new PhrasingPhrase record." do
93
+ visit root_path
94
+ expect(PhrasingPhrase.find_by_key('site.index.footer')).to be_nil
95
+ end
93
96
  end
94
97
  end
@@ -9,34 +9,34 @@ feature 'edit mode bubble' do
9
9
 
10
10
  it '(un)check edit mode checkbox' do
11
11
  edit_mode_checkbox = find(:css, ".onoffswitch-checkbox")
12
- edit_mode_checkbox.should be_checked
12
+ expect(edit_mode_checkbox).to be_checked
13
13
  edit_mode_checkbox.set(false)
14
- edit_mode_checkbox.should_not be_checked
14
+ expect(edit_mode_checkbox).not_to be_checked
15
15
  end
16
16
 
17
17
  it "phrases should have class 'phrasable_on' and contenteditable=true" do
18
- page.find('.header').first('.phrasable').text.should == 'The Header'
19
- page.find('.header').first('.phrasable')['class'].should == 'phrasable phrasable_on'
20
- page.find('.header').first('.phrasable')['contenteditable'].should == 'true'
18
+ expect(page.find('.header').first('.phrasable').text).to eq 'The Header'
19
+ expect(page.find('.header').first('.phrasable')['class']).to eq 'phrasable phrasable_on'
20
+ expect(page.find('.header').first('.phrasable')['contenteditable']).to eq 'true'
21
21
  end
22
22
 
23
23
  it 'should be able to visit phrasing index via edit_all icon' do
24
24
  find(:css, ".phrasing-edit-all-phrases-link").click
25
- current_path.should == phrasing_phrases_path
25
+ expect(current_path).to eq phrasing_phrases_path
26
26
  end
27
27
 
28
28
  xit "phrases should have class shouldn't have class phrasable on when edit mode is off", js: true do
29
29
  edit_mode_checkbox = find(:css, ".onoffswitch-checkbox")
30
30
  edit_mode_checkbox.click
31
- page.find('.header').first('.phrasable')['class'].should == 'phrasable'
31
+ expect(page.find('.header').first('.phrasable')['class']).to eq 'phrasable'
32
32
  end
33
33
 
34
34
  xit 'edit phrases', js: true do
35
35
  header_phrase = page.find('.header').first('.phrasable')
36
- header_phrase['class'].should == 'phrasable phrasable_on'
37
- header_phrase.text.should == 'The Header'
36
+ header_phrase['class'].should eq 'phrasable phrasable_on'
37
+ expect(header_phrase.text).to eq 'The Header'
38
38
  header_phrase.set "content"
39
- header_phrase.text.should == 'content'
39
+ expect(header_phrase.expect.text).to eq 'content'
40
40
  end
41
41
  end
42
42
 
@@ -54,50 +54,50 @@ feature "phrasing index" do
54
54
  end
55
55
 
56
56
  it " shows phrases" do
57
- page.should have_content 'foo'
58
- page.should have_content 'bar'
57
+ expect(page).to have_content 'foo'
58
+ expect(page).to have_content 'bar'
59
59
  end
60
60
 
61
61
  it "allows search by key" do
62
62
  fill_in 'search', with: 'foo'
63
63
  click_button 'Search'
64
- page.should have_content 'foo'
65
- page.should have_content 'bar'
64
+ expect(page).to have_content 'foo'
65
+ expect(page).to have_content 'bar'
66
66
  end
67
67
 
68
68
  it "allows search by key" do
69
69
  fill_in 'search', with: 'xfoo'
70
70
  click_button 'Search'
71
- page.should_not have_content 'foo'
72
- page.should_not have_content 'bar'
71
+ expect(page).not_to have_content 'foo'
72
+ expect(page).not_to have_content 'bar'
73
73
  end
74
74
 
75
75
  it "allows search by value" do
76
76
  fill_in 'search', with: 'bar'
77
77
  click_button 'Search'
78
- page.should have_content 'foo'
79
- page.should have_content 'bar'
78
+ expect(page).to have_content 'foo'
79
+ expect(page).to have_content 'bar'
80
80
  end
81
81
 
82
82
  it "allows search by value" do
83
83
  fill_in 'search', with: 'xbar'
84
84
  click_button 'Search'
85
- page.should_not have_content 'foo'
86
- page.should_not have_content 'bar'
85
+ expect(page).not_to have_content 'foo'
86
+ expect(page).not_to have_content 'bar'
87
87
  end
88
88
 
89
89
  it "searches in the middles of strings" do
90
90
  FactoryGirl.create(:phrasing_phrase, key: "site.index.something")
91
91
  fill_in 'search', with: 'index'
92
92
  click_button 'Search'
93
- page.should have_content 'site.index.something'
93
+ expect(page).to have_content 'site.index.something'
94
94
  end
95
95
 
96
96
  it "can show all" do
97
97
  FactoryGirl.create(:phrasing_phrase, key: "foe", value: "beer")
98
98
  click_button 'Search'
99
- page.should have_content 'foo'
100
- page.should have_content 'foe'
99
+ expect(page).to have_content 'foo'
100
+ expect(page).to have_content 'foe'
101
101
  end
102
102
 
103
103
  it 'not null values first, global order by key' do
@@ -105,7 +105,7 @@ feature "phrasing index" do
105
105
  FactoryGirl.create(:phrasing_phrase, key: "foo2", value: "beer")
106
106
  FactoryGirl.create(:phrasing_phrase, key: "foo3", value: nil)
107
107
  visit phrasing_phrases_path
108
- page.body.should =~ /foo[\s\S]*foo2[\s\S]*foo1[\s\S]*foo3/
108
+ expect(page.body).to match /foo[\s\S]*foo2[\s\S]*foo1[\s\S]*foo3/
109
109
  end
110
110
 
111
111
  context "more than one locale" do
@@ -120,94 +120,94 @@ feature "phrasing index" do
120
120
  it "nil locale, blank search" do
121
121
  # impossible for user to replicate this case
122
122
  visit phrasing_phrases_path('search' => '', 'commit' => 'Search')
123
- page.should have_content 'bar1'
124
- page.should_not have_content 'bar2'
125
- page.should_not have_content 'bar3'
123
+ expect(page).to have_content 'bar1'
124
+ expect(page).not_to have_content 'bar2'
125
+ expect(page).not_to have_content 'bar3'
126
126
  end
127
127
 
128
128
  it "nil locale, present search" do
129
129
  # impossible for user to replicate this case
130
130
  visit phrasing_phrases_path('search' => 'foo', 'commit' => 'Search')
131
- page.should have_content 'bar1'
132
- page.should_not have_content 'bar2'
133
- page.should_not have_content 'bar3'
131
+ expect(page).to have_content 'bar1'
132
+ expect(page).not_to have_content 'bar2'
133
+ expect(page).not_to have_content 'bar3'
134
134
  visit phrasing_phrases_path('search' => 'fuu', 'commit' => 'Search')
135
- page.should_not have_content 'foo'
135
+ expect(page).not_to have_content 'foo'
136
136
  end
137
137
 
138
138
  it "blank locale, foo search" do
139
139
  # impossible for user to replicate this case
140
140
  visit phrasing_phrases_path('locale' => '', 'commit' => 'Search')
141
- page.should have_content 'foo'
141
+ expect(page).to have_content 'foo'
142
142
  end
143
143
 
144
144
  it "blank locale, blank search" do
145
145
  select '', from: 'locale'
146
146
  click_button 'Search'
147
- page.should have_content 'bar1'
148
- page.should have_content 'bar2'
149
- page.should have_content 'bar3'
147
+ expect(page).to have_content 'bar1'
148
+ expect(page).to have_content 'bar2'
149
+ expect(page).to have_content 'bar3'
150
150
  end
151
151
 
152
152
  it "blank locale, present search" do
153
153
  select '', from: 'locale'
154
154
  fill_in 'search', with: 'foo'
155
155
  click_button 'Search'
156
- page.should have_content 'bar1'
157
- page.should have_content 'bar2'
158
- page.should have_content 'bar3'
156
+ expect(page).to have_content 'bar1'
157
+ expect(page).to have_content 'bar2'
158
+ expect(page).to have_content 'bar3'
159
159
  fill_in 'search', with: 'fuu'
160
160
  click_button 'Search'
161
- page.should_not have_content 'foo'
161
+ expect(page).not_to have_content 'foo'
162
162
  end
163
163
 
164
164
  it "present locale, foo search" do
165
165
  # impossible for user to replicate this case
166
166
  visit phrasing_phrases_path('locale' => 'en', 'commit' => 'Search')
167
- page.should have_content 'foo'
167
+ expect(page).to have_content 'foo'
168
168
  end
169
169
 
170
170
  it "present locale, blank search" do
171
171
  select 'en', from: 'locale'
172
172
  click_button 'Search'
173
- page.should have_content 'bar1'
174
- page.should_not have_content 'bar2'
175
- page.should_not have_content 'bar3'
173
+ expect(page).to have_content 'bar1'
174
+ expect(page).not_to have_content 'bar2'
175
+ expect(page).not_to have_content 'bar3'
176
176
  select 'fa', from: 'locale'
177
177
  click_button 'Search'
178
- page.should_not have_content 'bar1'
179
- page.should have_content 'bar2'
180
- page.should_not have_content 'bar3'
178
+ expect(page).not_to have_content 'bar1'
179
+ expect(page).to have_content 'bar2'
180
+ expect(page).not_to have_content 'bar3'
181
181
  select 'it', from: 'locale'
182
182
  click_button 'Search'
183
- page.should_not have_content 'bar1'
184
- page.should_not have_content 'bar2'
185
- page.should have_content 'bar3'
183
+ expect(page).not_to have_content 'bar1'
184
+ expect(page).not_to have_content 'bar2'
185
+ expect(page).to have_content 'bar3'
186
186
  end
187
187
 
188
188
  it "present locale, present search" do
189
189
  select 'en', from: 'locale'
190
190
  fill_in 'search', with: 'foo'
191
191
  click_button 'Search'
192
- page.should have_content 'bar1'
193
- page.should_not have_content 'bar2'
194
- page.should_not have_content 'bar3'
192
+ expect(page).to have_content 'bar1'
193
+ expect(page).not_to have_content 'bar2'
194
+ expect(page).not_to have_content 'bar3'
195
195
  select 'fa', from: 'locale'
196
196
  fill_in 'search', with: 'foo'
197
197
  click_button 'Search'
198
- page.should_not have_content 'bar1'
199
- page.should have_content 'bar2'
200
- page.should_not have_content 'bar3'
198
+ expect(page).not_to have_content 'bar1'
199
+ expect(page).to have_content 'bar2'
200
+ expect(page).not_to have_content 'bar3'
201
201
  select 'it', from: 'locale'
202
202
  fill_in 'search', with: 'foo'
203
203
  click_button 'Search'
204
- page.should_not have_content 'bar1'
205
- page.should_not have_content 'bar2'
206
- page.should have_content 'bar3'
204
+ expect(page).not_to have_content 'bar1'
205
+ expect(page).not_to have_content 'bar2'
206
+ expect(page).to have_content 'bar3'
207
207
  select 'en', from: 'locale'
208
208
  fill_in 'search', with: 'fuu'
209
209
  click_button 'Search'
210
- page.should_not have_content 'foo'
210
+ expect(page).not_to have_content 'foo'
211
211
  end
212
212
 
213
213
  end
@@ -219,8 +219,9 @@ feature "phrasing edit" do
219
219
  FactoryGirl.create(:phrasing_phrase, key: "foo", value: "bar")
220
220
  visit phrasing_phrases_path
221
221
  end
222
+
222
223
  after do
223
- PhrasingPhrase.delete_all
224
+ PhrasingPhrase.destroy_all
224
225
  end
225
226
 
226
227
  scenario "visit edit form" do
@@ -240,18 +241,61 @@ feature "phrasing update" do
240
241
  click_link 'foo'
241
242
  end
242
243
 
244
+ scenario 'has delete and update buttons' do
245
+ expect(page).to have_selector(:link_or_button, 'Delete Phrase')
246
+ expect(page).to have_selector(:link_or_button, 'Update')
247
+ end
248
+
243
249
  scenario "update" do
244
250
  fill_in "phrasing_phrase[value]", with: 'baz'
245
251
  click_button "Update"
246
- current_path.should == phrasing_phrases_path
247
- PhrasingPhrase.find_by_key("foo").value.should == 'baz'
248
- page.should have_content "foo updated!"
252
+ expect(current_path).to eq phrasing_phrases_path
253
+ expect(PhrasingPhrase.find_by_key("foo").value).to eq 'baz'
254
+ expect(page).to have_content "foo updated!"
249
255
  end
250
256
  end
251
257
 
258
+ feature 'phrase versions' do
259
+ before do
260
+ phrase = FactoryGirl.create(:phrasing_phrase, key: "foo", value: "bar")
261
+ visit edit_phrasing_phrase_path(phrase)
262
+ end
263
+
264
+ def update_phrase
265
+ fill_in "phrasing_phrase[value]", with: 'baz'
266
+ click_button "Update"
267
+ end
268
+
269
+ it " shows phrases" do
270
+ expect(page).to have_content 'foo'
271
+ expect(page).to have_content 'bar'
272
+ end
273
+
274
+ it 'update a phrase and get first phrase versions' do
275
+ expect(PhrasingPhraseVersion.count).to eq 0
276
+ update_phrase
277
+ expect(PhrasingPhraseVersion.count).to eq 1
278
+ expect(current_path).to eq phrasing_phrases_path
279
+ expect(PhrasingPhrase.find_by_key("foo").value).to eq 'baz'
280
+ expect(page).to have_content "foo updated!"
281
+ end
282
+
283
+ it 'view first phrase' do
284
+ expect(PhrasingPhraseVersion.count).to eq 0
285
+ update_phrase
286
+ expect(PhrasingPhraseVersion.count).to eq 1
287
+ click_link 'foo'
288
+ expect(page).to have_selector(:link_or_button, 'Delete')
289
+ expect(page).to have_selector(:link_or_button, 'Revert')
290
+ expect(page).to have_content 'bar'
291
+ expect(page).to have_content 'baz'
292
+ end
293
+
294
+ end
295
+
252
296
  feature "downloading and uploading yaml files" do
253
297
  after do
254
- PhrasingPhrase.delete_all
298
+ PhrasingPhrase.destroy_all
255
299
  end
256
300
 
257
301
  it "round-trips the YAML" do
@@ -260,13 +304,13 @@ feature "downloading and uploading yaml files" do
260
304
  FactoryGirl.create(:phrasing_phrase, key: "a.b.foo3", value: "bar3")
261
305
  FactoryGirl.create(:phrasing_phrase, key: "c.foo4", value: "bar4")
262
306
  FactoryGirl.create(:phrasing_phrase, key: 2, value: "bar5")
263
- assert PhrasingPhrase.count == 5
307
+ expect(PhrasingPhrase.count).to eq 5
264
308
 
265
309
  visit import_export_phrasing_phrases_path
266
310
 
267
311
  click_link 'Download as YAML'
268
312
  PhrasingPhrase.destroy_all
269
- assert PhrasingPhrase.count == 0
313
+ expect(PhrasingPhrase.count).to eq 0
270
314
 
271
315
  yaml = page.source
272
316
  file = Tempfile.new 'phrasing'
@@ -278,12 +322,12 @@ feature "downloading and uploading yaml files" do
278
322
  click_button "Upload"
279
323
  file.unlink
280
324
 
281
- assert PhrasingPhrase.count == 5
282
- assert PhrasingPhrase.find_by_key("a.foo1").value == "bar1"
283
- assert PhrasingPhrase.find_by_key("a.foo2:").value == "bar2"
284
- assert PhrasingPhrase.find_by_key("a.b.foo3").value == "bar3"
285
- assert PhrasingPhrase.find_by_key("c.foo4").value == "bar4"
286
- assert PhrasingPhrase.find_by_key(2).value == "bar5"
325
+ expect(PhrasingPhrase.count).to eq 5
326
+ expect(PhrasingPhrase.find_by_key("a.foo1").value).to eq "bar1"
327
+ expect(PhrasingPhrase.find_by_key("a.foo2:").value).to eq "bar2"
328
+ expect(PhrasingPhrase.find_by_key("a.b.foo3").value).to eq "bar3"
329
+ expect(PhrasingPhrase.find_by_key("c.foo4").value).to eq "bar4"
330
+ expect(PhrasingPhrase.find_by_key(2).value).to eq "bar5"
287
331
  end
288
332
 
289
333
  it "round-trips the yaml with complicated text" do
@@ -303,7 +347,7 @@ feature "downloading and uploading yaml files" do
303
347
  attach_file "file", file.path
304
348
  click_button "Upload"
305
349
  file.unlink
306
- assert PhrasingPhrase.find_by_key("a.foo").value == value
350
+ expect(PhrasingPhrase.find_by_key("a.foo").value).to eq value
307
351
  end
308
352
 
309
353
  it "gives 400 on bad upload" do
@@ -315,9 +359,9 @@ feature "downloading and uploading yaml files" do
315
359
  attach_file "file", file.path
316
360
  click_button "Upload"
317
361
  file.unlink
318
- page.status_code.should == 400
319
- page.should have_content("There was an error processing your upload!")
320
- assert PhrasingPhrase.count == 0
362
+ expect(page.status_code).to eq 400
363
+ expect(page).to have_content("There was an error processing your upload!")
364
+ expect(PhrasingPhrase.count).to eq 0
321
365
  end
322
366
 
323
367
  end
@@ -326,7 +370,7 @@ feature "locales" do
326
370
  before do
327
371
  end
328
372
  after do
329
- PhrasingPhrase.delete_all
373
+ PhrasingPhrase.destroy_all
330
374
  end
331
375
  it "imports yaml containing multiple locales" do
332
376
  file = Tempfile.new 'phrasing'
@@ -343,13 +387,13 @@ feature "locales" do
343
387
  click_button "Upload"
344
388
  file.unlink
345
389
 
346
- assert PhrasingPhrase.count == 2
390
+ expect(PhrasingPhrase.count).to eq 2
347
391
  a = PhrasingPhrase.where(locale: 'en').first
348
- assert a.key == 'hello'
349
- assert a.value == 'world'
392
+ expect(a.key).to eq 'hello'
393
+ expect(a.value).to eq 'world'
350
394
  b = PhrasingPhrase.where(locale: 'es').first
351
- assert b.key == 'hello'
352
- assert b.value == 'mundo'
395
+ expect(b.key).to eq 'hello'
396
+ expect(b.value).to eq 'mundo'
353
397
  end
354
398
 
355
399
  it "exports yaml containing multiple locales" do
@@ -358,8 +402,8 @@ feature "locales" do
358
402
 
359
403
  visit download_phrasing_phrases_path
360
404
  yaml = page.source
361
- assert yaml =~ /en:\s*hello: world/
362
- assert yaml =~ /es:\s*hello: mundo/
405
+ expect(yaml).to match(/en:\s*hello: world/)
406
+ expect(yaml).to match(/es:\s*hello: mundo/)
363
407
  end
364
408
 
365
409
  end