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.
- checksums.yaml +4 -4
- data/.travis.yml +8 -11
- data/CHANGELOG.md +0 -20
- data/Gemfile +4 -1
- data/README-3.md +134 -0
- data/README.md +10 -14
- data/Release_notes_version_4.md +26 -0
- data/app/assets/javascripts/phrasing.js.erb +37 -17
- data/app/assets/stylesheets/phrasing_edit_mode_bubble.css.scss +3 -3
- data/app/controllers/phrasing_phrase_versions_controller.rb +4 -4
- data/app/controllers/phrasing_phrases_controller.rb +42 -75
- data/app/helpers/inline_helper.rb +24 -31
- data/app/models/phrasing_phrase.rb +29 -23
- data/app/views/phrasing/_production_warning.html.haml +0 -2
- data/app/views/phrasing_phrases/edit.html.haml +2 -2
- data/app/views/phrasing_phrases/import_export.html.haml +0 -5
- data/config/routes.rb +11 -9
- data/lib/generators/phrasing/phrasing_generator.rb +26 -0
- data/lib/generators/phrasing/templates/app/helpers/phrasing_helper.rb +12 -0
- data/lib/generators/phrasing/templates/config/initializers/phrasing.rb +11 -0
- data/{db/migrate/20131010101010_create_phrasing_phrase_versions.rb → lib/generators/phrasing/templates/db/migrate/create_phrasing_phrase_versions.rb} +2 -2
- data/{db/migrate/20120313191745_create_phrasing_phrases.rb → lib/generators/phrasing/templates/db/migrate/create_phrasing_phrases.rb} +2 -2
- data/lib/phrasing.rb +11 -37
- data/lib/phrasing/version.rb +2 -2
- data/phrasing.gemspec +1 -3
- data/spec/features/dummy_spec.rb +27 -24
- data/spec/features/phrasing_spec.rb +128 -84
- data/spec/lib/phrasing_spec.rb +50 -50
- metadata +14 -26
- data/4.0.0_changes.md +0 -1
- data/lib/phrasing/implementation.rb +0 -21
- data/lib/phrasing/simple.rb +0 -3
- data/lib/tasks/phrasing_tasks.rake +0 -69
data/lib/phrasing.rb
CHANGED
@@ -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 +=
|
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
|
data/lib/phrasing/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Phrasing
|
2
|
-
VERSION = "
|
3
|
-
end
|
2
|
+
VERSION = "4.0.0rc1"
|
3
|
+
end
|
data/phrasing.gemspec
CHANGED
@@ -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
|
data/spec/features/dummy_spec.rb
CHANGED
@@ -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.
|
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.
|
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').
|
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').
|
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').
|
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').
|
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.
|
33
|
-
page.
|
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.
|
39
|
+
expect(page).to have_content 'Strong header'
|
40
40
|
visit root_path
|
41
|
-
page.
|
42
|
-
page.
|
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.
|
48
|
-
page.
|
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.
|
61
|
-
page.
|
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.
|
66
|
-
page.
|
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.
|
71
|
-
page.
|
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
|
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.
|
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.
|
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.
|
12
|
+
expect(edit_mode_checkbox).to be_checked
|
13
13
|
edit_mode_checkbox.set(false)
|
14
|
-
edit_mode_checkbox.
|
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.
|
19
|
-
page.find('.header').first('.phrasable')['class'].
|
20
|
-
page.find('.header').first('.phrasable')['contenteditable'].
|
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.
|
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'].
|
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
|
37
|
-
header_phrase.text.
|
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.
|
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.
|
58
|
-
page.
|
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.
|
65
|
-
page.
|
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.
|
72
|
-
page.
|
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.
|
79
|
-
page.
|
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.
|
86
|
-
page.
|
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.
|
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.
|
100
|
-
page.
|
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.
|
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.
|
124
|
-
page.
|
125
|
-
page.
|
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.
|
132
|
-
page.
|
133
|
-
page.
|
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.
|
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.
|
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.
|
148
|
-
page.
|
149
|
-
page.
|
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.
|
157
|
-
page.
|
158
|
-
page.
|
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.
|
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.
|
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.
|
174
|
-
page.
|
175
|
-
page.
|
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.
|
179
|
-
page.
|
180
|
-
page.
|
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.
|
184
|
-
page.
|
185
|
-
page.
|
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.
|
193
|
-
page.
|
194
|
-
page.
|
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.
|
199
|
-
page.
|
200
|
-
page.
|
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.
|
205
|
-
page.
|
206
|
-
page.
|
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.
|
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.
|
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.
|
247
|
-
PhrasingPhrase.find_by_key("foo").value.
|
248
|
-
page.
|
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.
|
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
|
-
|
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
|
-
|
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
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
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
|
-
|
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.
|
319
|
-
page.
|
320
|
-
|
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.
|
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
|
-
|
390
|
+
expect(PhrasingPhrase.count).to eq 2
|
347
391
|
a = PhrasingPhrase.where(locale: 'en').first
|
348
|
-
|
349
|
-
|
392
|
+
expect(a.key).to eq 'hello'
|
393
|
+
expect(a.value).to eq 'world'
|
350
394
|
b = PhrasingPhrase.where(locale: 'es').first
|
351
|
-
|
352
|
-
|
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
|
-
|
362
|
-
|
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
|