phrasing 4.2.1 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ac13135c189add2c1c995372d8afaff63863d697
4
- data.tar.gz: a2a0ac009155ff6a8438e1e086567ef326e08539
2
+ SHA256:
3
+ metadata.gz: 68ab27186294351f99ee4791e5db6483370f1212b1a9deeeeed179dac6140131
4
+ data.tar.gz: 21a84f6c4b00e0830a1f095ae584b36665e3f80433068cd12299021b470eddbf
5
5
  SHA512:
6
- metadata.gz: 31618d8667c75fad47e5dc4cbe460af00dd8c48916f53831b8c2eea722795616e3dbf8d8c0f62bcf0b5d5a2ed4ee19df7d34f2f6302efedc8c22e78b0553a400
7
- data.tar.gz: c9f5575d6f24427aed3b837a0881129142eadae7d0a504c5bdc629183843b310c899fcacad487c974909ab308ba76cc4f53996bfff19fc3a70a0f4e75a4b8ca2
6
+ metadata.gz: f8663faf20ebd70d0b23039495df591020e8a6a1474f4ca8140fbc1a9302c1cd19bd471a16e9f71806095accbbe7c5f79cd1688c308b3777ea31d053ae1d95ff
7
+ data.tar.gz: b04b7dbcd065542d12ea6238d994a90ebf38dd78411e6953c4c4f521831e78acb8a2ca2b610f2ca2774d94972ef466f44b5dfee340d552348920adb09c17fc0a
data/.travis.yml CHANGED
@@ -1,16 +1,17 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  before_install:
4
- - gem update bundler
4
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
5
+ - gem install bundler -v '< 2'
5
6
  script:
6
7
  - RAILS_ENV=test bundle exec rake db:migrate --trace
7
8
  - bundle exec rspec spec/
8
9
 
9
10
  matrix:
10
11
  include:
11
- - rvm: 2.1.2
12
+ - rvm: 2.3.0
12
13
  env: "RAILS_VERSION=4.1.0"
13
- - rvm: 2.2.0
14
+ - rvm: 2.4.0
14
15
  env: "RAILS_VERSION=4.2.0"
15
- - rvm: 2.3.0
16
+ - rvm: 2.5.0
16
17
  env: "RAILS_VERSION=5.0.0"
data/CHANGELOG.md CHANGED
@@ -1,12 +1,55 @@
1
- # Phrasing Change Log
1
+ # Changelog
2
2
 
3
- ## 4.2.1 (Nov 5th, 2018)
3
+ ## [4.4.0](https://github.com/infinum/phrasing/tree/v4.4.0) (2021-12-23)
4
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v4.3.2...v4.4.0)
4
5
 
5
- Fix linear-gradient syntax to be W3C compliant.
6
+ ### Enhancements
6
7
 
7
- ## 4.2.0 (Sep 7th, 2018)
8
+ - Bump nokogiri version from 1.10.4 to 1.12.5 due to CVEs
9
+
10
+ ## [4.3.1](https://github.com/infinum/phrasing/tree/v4.3.1) (2019-09-03)
11
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v4.3.0...v4.3.1)
12
+
13
+ ### Enhancements
14
+
15
+ - Bump nokogiri version from 1.8.3 to 1.10.4 due to [security vulnerability](https://github.com/sparklemotion/nokogiri/issues/1915)
16
+
17
+ ## [4.3.2](https://github.com/infinum/phrasing/tree/v4.3.2) (2020-10-30)
18
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v4.3.1...v4.3.2)
19
+
20
+ ### Bugfixes
21
+
22
+ - Send `edit_mode_enabled` as parameter and reject phrasing update if not `true` - fixes issue [#90](https://github.com/infinum/phrasing/issues/90)
23
+
24
+ ## [4.3.1](https://github.com/infinum/phrasing/tree/v4.3.1) (2019-09-03)
25
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v4.3.0...v4.3.1)
26
+
27
+ ### Enhancements
28
+
29
+ - Bump nokogiri version from 1.8.3 to 1.10.4 due to [security vulnerability](https://github.com/sparklemotion/nokogiri/issues/1915)
30
+
31
+ ## [4.3.0](https://github.com/infinum/phrasing/tree/v4.3.0) (2019-06-13)
32
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v4.2.1...v4.3.0)
33
+
34
+ ### Enhancements
35
+
36
+ - Add support for Rails 6
37
+ - Remove jquery.turbolinks fix suggestion
38
+
39
+ ## [4.2.1](https://github.com/infinum/phrasing/tree/v4.2.1) (2018-11-05)
40
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v4.2.0...v4.2.1)
41
+
42
+ ### Enhancements
43
+
44
+ - Fix linear-gradient syntax to be W3C compliant.
45
+
46
+ ## [4.2.0](https://github.com/infinum/phrasing/tree/v4.2.0) (2018-09-07)
47
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v4.1.0...v4.2.0)
48
+
49
+ ### Enhancements
50
+
51
+ - bundler-audit reported that there are DoS and RCE vulnerabilities in nokogiri:
8
52
 
9
- bundler-audit reported that there are DoS and RCE vulnerabilities in nokogiri:
10
53
  ```
11
54
  Name: nokogiri
12
55
  Version: 1.6.8.1
@@ -25,30 +68,38 @@ Title: Revert libxml2 behavior in Nokogiri gem that could cause XSS
25
68
  Solution: upgrade to >= 1.8.3
26
69
  ```
27
70
 
28
- Bumped nokogiri to 1.8.3.
71
+ - Bumped nokogiri to 1.8.3.
72
+
73
+ ## [4.1.0](https://github.com/infinum/phrasing/tree/v4.1.0) (2018-05-17)
74
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v4.0.0...v4.1.0)
75
+
76
+ ### Bugfixes
29
77
 
30
- ## 4.1.0 (May 17th, 2018)
78
+ - Fix generated migration files for Rails 5
31
79
 
32
- Fix generated migration files for Rails 5
33
80
  ```
34
81
  Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for.
35
82
  ```
36
83
 
37
- Fixed Rails 5.2 deprecation issue with `class_name`:
84
+ - Fixed Rails 5.2 deprecation issue with `class_name`:
85
+
38
86
  ```
39
87
  A class was passed to :class_name but we are expecting a string.
40
88
  ```
41
89
 
42
- ## 4.0.0 (February 27th, 2018)
90
+ ## [4.0.0](https://github.com/infinum/phrasing/tree/v4.0.0) (2018-02-27)
91
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.10...v4.0.0)
92
+
93
+ ### Breaking changes
43
94
 
44
- ### Separation of I18n and Phrasing:
95
+ #### Separation of I18n and Phrasing:
45
96
 
46
- Phrasing no longer does monkeypatching over the I18n gem, so the I18n and Phrasings behaviors are completely separate.
97
+ Phrasing no longer does monkeypatching over the I18n gem, so the I18n and Phrasings behaviours are completely separate.
47
98
  When using the I18n.t() method, Phrasing will no longer copy the data from the translations file and continue to use translations from the database.
48
99
 
49
100
  However, when using the phrase(key) method, if the key doesn't currently exist in the PhrasingPhrase table, it will do a lookup in the translations file and copy the data from there to the database.
50
101
 
51
- ### Interpolation
102
+ #### Interpolation
52
103
 
53
104
  The interpolation option has been kicked out.
54
105
 
@@ -56,7 +107,7 @@ The problem with the interpolation option is that most clients won't understand
56
107
 
57
108
  If they try to erase parts of it, the developer also might end up being confused and the UI might get broken or at least ugly for some time until the developer fixes the issue.
58
109
 
59
- ### Loading asset dependencies
110
+ #### Loading asset dependencies
60
111
 
61
112
  From phrasing v4.0.0rc3, add your jquery files manually:
62
113
 
@@ -66,64 +117,95 @@ From phrasing v4.0.0rc3, add your jquery files manually:
66
117
  //= require phrasing
67
118
  ```
68
119
 
69
- ### Switching rake tasks with Rails generators
120
+ #### Switching rake tasks with Rails generators
70
121
 
71
122
  Since Rails comes with outofbox generators that enable easy existing file detection and similar behaviors, Phrasing 4 will use Rails generators instead of the old rake tasks.
72
123
 
73
124
  To run the initial setup generator, just do: `rails generate phrasing`
74
125
 
75
- ## 3.2.10 (October 2nd, 2015)
126
+ ## [3.2.10](https://github.com/infinum/phrasing/tree/v3.2.10) (2015-10-02)
127
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.9...v3.2.10)
128
+
129
+ ### Enhancements
130
+
131
+ - Change order parameters in PhrasingPhrases#index to support SQLServer.
76
132
 
77
- Change order parameters in PhrasingPhrases#index to support SQLServer.
133
+ ## [3.2.9](https://github.com/infinum/phrasing/tree/v3.2.9) (2015-01-07)
134
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.8...v3.2.9)
78
135
 
79
- ## 3.2.9 (January 7th, 2015)
136
+ ### Enhancements
80
137
 
81
- Require only haml, not haml-rails.
138
+ - Require only haml, not haml-rails.
82
139
 
83
- ## 3.2.8 (January 6th, 2015)
140
+ ## [3.2.8](https://github.com/infinum/phrasing/tree/v3.2.8) (2015-01-06)
141
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.7...v3.2.8)
84
142
 
85
- Fix confirm dialogs when deleting phrases and phrase versions.
143
+ ### Bugfixes
86
144
 
87
- ## 3.2.7 (October 3rd, 2014)
145
+ - Fix confirm dialogs when deleting phrases and phrase versions.
88
146
 
89
- Add a config option to set a parent controller to Phrasing Engine Controllers.
147
+ ## [3.2.7](https://github.com/infinum/phrasing/tree/v3.2.7) (2014-10-03)
148
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.6...v3.2.7)
90
149
 
91
- ## 3.2.6 (September 15th, 2014)
150
+ ### Enhancements
92
151
 
93
- Show Home page only when view responds to :root_path.
152
+ - Add a config option to set a parent controller to Phrasing Engine Controllers.
94
153
 
95
- ## 3.2.5 (June 17th, 2014)
154
+ ## [3.2.6](https://github.com/infinum/phrasing/tree/v3.2.6) (2014-09-15)
155
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.5...v3.2.6)
96
156
 
97
- Added index for phrasing_phrase_id in versions table.
157
+ ### Enhancements
98
158
 
99
- ## 3.2.4 (May 8th, 2014)
159
+ - Show Home page only when view responds to :root_path.
100
160
 
101
- Changed InlineHelper#phrasing_polymorphic_url to use rails path helper.
161
+ ## [3.2.5](https://github.com/infinum/phrasing/tree/v3.2.5) (2014-06-17)
162
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.4...v3.2.5)
102
163
 
103
- ## 3.2.3 (March 3rd, 2014)
164
+ ### Enhancements
104
165
 
105
- Exctracted import/export functionality to Phrasing::Serializer. Importer now accepts nested yaml files, just like the ones from /config/locales.
166
+ - Added index for phrasing_phrase_id in versions table.
106
167
 
107
- ## 3.2.2 (Feb 19th, 2014)
168
+ ## [3.2.4](https://github.com/infinum/phrasing/tree/v3.2.4) (2014-05-08)
169
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.3...v3.2.4)
108
170
 
109
- Scope option for phrases added:
171
+ ### Enhancements
172
+
173
+ - Changed InlineHelper#phrasing_polymorphic_url to use rails path helper.
174
+
175
+ ## [3.2.3](https://github.com/infinum/phrasing/tree/v3.2.3) (2014-03-03)
176
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.2...v3.2.3)
177
+
178
+ ### Enhancements
179
+
180
+ - Exctracted import/export functionality to Phrasing::Serializer. Importer now accepts nested yaml files, just like the ones from /config/locales.
181
+
182
+ ## [3.2.2](https://github.com/infinum/phrasing/tree/v3.2.2) (2014-02-19)
183
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.1...v3.2.2)
184
+
185
+ ### Enhancements
186
+
187
+ - Scope option for phrases added:
110
188
 
111
189
  scope: 'homepage.footer' # add scopes just like you would w/ I18.n. If the first argument is 'test', than the key would be 'homepage.footer.test'
112
190
 
113
- Change in generated migration file:
191
+ - Change in generated migration file:
114
192
 
115
193
  :phrasing_phrase_id changed from t.string to t.integer.
116
194
 
117
- Change in PhrasingPhrasesController#index:
195
+ - Change in PhrasingPhrasesController#index:
118
196
 
119
197
  Fix order clause so it runs on Rails 3.2 and MySQL
120
198
 
121
- ## 3.2.1 (Jan 29th, 2014)
199
+ ## [3.2.1](https://github.com/infinum/phrasing/tree/v3.2.1) (2014-01-29)
200
+ [Full Changelog](https://github.com/infinum/phrasing/compare/v3.2.0...v3.2.1)
201
+
202
+ ### Enhancements
122
203
 
123
- Created PhrasingPhrase.search_i18n_and_create_phrase for proper lookup of translations in config/locales.
204
+ - Created PhrasingPhrase.search_i18n_and_create_phrase for proper lookup of translations in config/locales.
124
205
 
125
- ## 3.2.0 (Jan 16th, 2014)
206
+ ## [3.2.0](https://github.com/infinum/phrasing/tree/v3.2.0) (2014-01-16)
126
207
 
127
- New design for edit mode bubble.
208
+ ### Enhancements
128
209
 
129
- Non breaking IE9 javascript fix.
210
+ - New design for edit mode bubble.
211
+ - Non breaking IE9 javascript fix.
data/Gemfile CHANGED
@@ -2,17 +2,18 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- rails_version = ENV['RAILS_VERSION'] || '5.0.0'
5
+ rails_version = ENV['RAILS_VERSION'] || '5.2.4'
6
6
 
7
- gem 'nokogiri', '~> 1.8.3'
7
+ gem 'nokogiri', '~> 1.12.5'
8
8
  gem 'rails', "~> #{rails_version}"
9
9
 
10
10
  gem 'capybara'
11
- gem 'factory_girl_rails'
11
+ gem 'factory_bot_rails'
12
12
  gem 'jasmine-core', '~> 2.9.1'
13
13
  gem 'jasmine-rails'
14
14
  gem 'poltergeist'
15
15
  gem 'pry-rails'
16
+ gem 'rdoc'
16
17
  gem 'rspec-rails', '~> 3.7.1'
17
18
  gem 'sass'
18
- gem 'sqlite3'
19
+ gem 'sqlite3', '~> 1.4.2'
data/README.md CHANGED
@@ -100,14 +100,13 @@ config.allow_update_on_all_models_and_attributes = true
100
100
 
101
101
  ## Turbolinks
102
102
 
103
- If you're experiencing problems with Rails apps using Turbolinks, include the [jQuery-turbolinks](https://github.com/kossnocorp/jquery.turbolinks) gem in your application and simply require it in the following order:
103
+ If you're using Turbolinks make sure the phrasing gem is required after it:
104
104
 
105
105
  ```javascript
106
106
  //= require jquery
107
107
  //= require jquery_ujs
108
- //= require jquery.turbolinks
109
- //= require phrasing
110
108
  //= require turbolinks
109
+ //= require phrasing
111
110
  ```
112
111
 
113
112
  ## Phrasing Appearance
@@ -119,7 +119,7 @@ var phrasing_setup = function(){
119
119
  $.ajax({
120
120
  type: "PUT",
121
121
  url: url,
122
- data: { new_value: content },
122
+ data: { new_value: content, edit_mode_enabled: Phrasing.isEditModeEnabled() },
123
123
  success: function(e){
124
124
  userTriggeredPhrasingDOMChange = false;
125
125
  if(content === "Empty"){
@@ -135,6 +135,7 @@ var phrasing_setup = function(){
135
135
  }
136
136
  },
137
137
  error: function(e){
138
+ console.log("Phrasing:", e.responseText);
138
139
  statusBubbleWidget.error();
139
140
  }
140
141
  });
@@ -163,7 +164,11 @@ var phrasing_setup = function(){
163
164
  }
164
165
  };
165
166
 
166
- $(document).ready(phrasing_setup);
167
+ if(typeof Turbolinks == "object") {
168
+ $(document).on('turbolinks:load', phrasing_setup);
169
+ } else {
170
+ $(document).ready(phrasing_setup);
171
+ }
167
172
 
168
173
  $(document).on('page:before-change', function() {
169
174
  Phrasing.Bus.off();
@@ -1,3 +1,5 @@
1
+ require 'phrasing/string'
2
+
1
3
  class PhrasingPhrasesController < Phrasing.parent_controller.constantize
2
4
 
3
5
  layout 'phrasing'
@@ -66,6 +68,7 @@ class PhrasingPhrasesController < Phrasing.parent_controller.constantize
66
68
  klass, attribute = params[:klass], params[:attribute]
67
69
 
68
70
  return render status: 403, text: 'Phrase not whitelisted' unless Phrasing.whitelisted?(klass, attribute)
71
+ return render status: 403, text: 'Edit mode is disabled' unless edit_mode?
69
72
 
70
73
  record = klass.classify.constantize.find(params[:id])
71
74
 
@@ -88,4 +91,7 @@ class PhrasingPhrasesController < Phrasing.parent_controller.constantize
88
91
  PhrasingPhrase.fuzzy_search(params[:search], params[:locale])
89
92
  end
90
93
 
94
+ def edit_mode?
95
+ Phrasing::String.new(params[:edit_mode_enabled]).to_bool
96
+ end
91
97
  end
@@ -25,12 +25,10 @@ class PhrasingGenerator < Rails::Generators::Base
25
25
  end
26
26
 
27
27
  def migration_version
28
- if rails5?
29
- "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
30
- end
28
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if rails_major_version >= 5
31
29
  end
32
30
 
33
- def rails5?
34
- Rails.version.start_with? '5'
31
+ def rails_major_version
32
+ Rails.version.first.to_i
35
33
  end
36
34
  end
@@ -0,0 +1,33 @@
1
+ module Phrasing
2
+ class String
3
+ attr_reader :value
4
+
5
+ def initialize(value)
6
+ @value = value
7
+ end
8
+
9
+ def to_bool
10
+ if major_version >= 5
11
+ ActiveModel::Type::Boolean.new.cast(value)
12
+ elsif major_version == 4 && minor_version >= 2
13
+ ActiveRecord::Type::Boolean.new.type_cast_from_database(value)
14
+ else
15
+ ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value)
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def major_version
22
+ rails_version.first.to_i
23
+ end
24
+
25
+ def minor_version
26
+ rails_version.second.to_i
27
+ end
28
+
29
+ def rails_version
30
+ @rails_version ||= ::Rails.version.split('.')
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module Phrasing
2
- VERSION = '4.2.1'.freeze
2
+ VERSION = '4.4.0'.freeze
3
3
  end
data/lib/phrasing.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'phrasing'
2
2
  require 'phrasing/serializer'
3
+ require 'phrasing/string'
3
4
  require 'phrasing/rails/engine'
4
5
  require 'jquery-rails'
5
6
  require 'haml'
@@ -6,29 +6,61 @@ describe PhrasingPhrasesController do
6
6
  get :index
7
7
  expect(response).to render_template(:index)
8
8
  end
9
+ end
10
+
11
+ describe 'PUT #update' do
12
+ let(:phrase) { FactoryBot.create(:phrasing_phrase, value: 'old_value') }
13
+
14
+ context 'when edit model is enabled' do
15
+ it 'updates phrase' do
16
+ expect do
17
+ xhr(
18
+ :put,
19
+ :update,
20
+ klass: 'PhrasingPhrase',
21
+ attribute: 'value',
22
+ id: phrase.id,
23
+ new_value: 'new_value',
24
+ edit_model_enabled: 'true'
25
+ )
26
+ end.to change { phrase.reload.value }.from('old_value').to('new_value')
9
27
 
10
- let(:phrase) { FactoryGirl.create(:phrasing_phrase, value: 'old_value') }
28
+ expect(response.code).to eq('200')
29
+ end
11
30
 
12
- it 'updates phrase' do
13
- expect do
14
- xhr(:put, :update, klass: 'PhrasingPhrase',
15
- attribute: 'value',
16
- id: phrase.id,
17
- new_value: 'new_value')
18
- end.to change { phrase.reload.value }.from('old_value').to('new_value')
31
+ it "doesn't update locale" do
32
+ expect do
33
+ xhr(
34
+ :put,
35
+ :update,
36
+ klass: 'PhrasingPhrase',
37
+ attribute: 'locale',
38
+ id: phrase.id,
39
+ new_value: 'de',
40
+ edit_model_enabled: 'true'
41
+ )
42
+ end.to_not(change { phrase.reload.locale })
19
43
 
20
- expect(response.code).to eq('200')
44
+ expect(response.code).to eq('403')
45
+ end
21
46
  end
22
47
 
23
- it 'updates phrase' do
24
- expect do
25
- xhr(:put, :update, klass: 'PhrasingPhrase',
26
- attribute: 'locale',
27
- id: phrase.id,
28
- new_value: 'de')
29
- end.to_not change { phrase.reload.locale }
48
+ context 'when edit mode is disabled' do
49
+ it "doesn't update phrase" do
50
+ expect do
51
+ xhr(
52
+ :put,
53
+ :update,
54
+ klass: 'PhrasingPhrase',
55
+ attribute: 'value',
56
+ id: phrase.id,
57
+ new_value: 'new_value',
58
+ edit_model_enabled: 'false'
59
+ )
60
+ end.not_to(change { phrase.reload.value })
30
61
 
31
- expect(response.code).to eq('403')
62
+ expect(response.code).to eq('403')
63
+ end
32
64
  end
33
65
  end
34
66
  end
@@ -43,4 +43,3 @@ module Dummy
43
43
  config.assets.version = '1.0'
44
44
  end
45
45
  end
46
-
@@ -5,3 +5,4 @@
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
7
  Dummy::Application.config.secret_token = '58a2a6a84d84c3e438f9ca2616323039174f7da3337e52de287033934caa5d32051779feec0aba01731cd4811d60150b208b856b706bee47f510c8a0648f1600'
8
+ Dummy::Application.config.secret_key_base = '91f7361433a40ea1fb938722ec727bd89312d0a2431a0e3f2770ebf4fe5ada502e8e9920ce5743e965c219cc153ef9f68fbcfd0f4c837cdb96174dc4068f3a69'
@@ -1,12 +1,11 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  sequence :string do |n|
3
3
  "string%09d" % n
4
4
  end
5
-
5
+
6
6
  factory :phrasing_phrase do
7
- key { FactoryGirl.generate(:string) }
8
- value { FactoryGirl.generate(:string) }
9
- locale I18n.default_locale
7
+ key { FactoryBot.generate(:string) }
8
+ value { FactoryBot.generate(:string) }
9
+ locale { I18n.default_locale }
10
10
  end
11
11
  end
12
-
@@ -9,7 +9,7 @@ feature "use #phrase" do
9
9
 
10
10
  it "should see the header phrase modified if created before visiting" do
11
11
  PhrasingPhrase.where(key: 'site.index.header').destroy_all
12
- FactoryGirl.create(:phrasing_phrase, key: 'site.index.header', value: 'The Header1')
12
+ FactoryBot.create(:phrasing_phrase, key: 'site.index.header', value: 'The Header1')
13
13
  visit root_path
14
14
  expect(page).to have_content 'The Header1'
15
15
  end
@@ -30,7 +30,7 @@ feature "use #phrase" do
30
30
 
31
31
  it "shows the phrasing_phrase instead of the yaml" do
32
32
  PhrasingPhrase.where(key: 'site.index.header').destroy_all
33
- FactoryGirl.create(:phrasing_phrase, key: 'site.index.header', value: 'A different header')
33
+ FactoryBot.create(:phrasing_phrase, key: 'site.index.header', value: 'A different header')
34
34
  visit root_path
35
35
  expect(page).not_to have_content 'The Header'
36
36
  expect(page).to have_content 'A different header'
@@ -38,7 +38,7 @@ feature "use #phrase" do
38
38
 
39
39
  it "allows to treat every translation as html safe" do
40
40
  PhrasingPhrase.where(key: 'site.index.header').destroy_all
41
- FactoryGirl.create(:phrasing_phrase, key: 'site.index.header', value: '<strong>Strong header</strong>')
41
+ FactoryBot.create(:phrasing_phrase, key: 'site.index.header', value: '<strong>Strong header</strong>')
42
42
  visit root_path
43
43
  expect(page).to have_content 'Strong header'
44
44
  visit root_path
@@ -93,8 +93,8 @@ feature "locales" do
93
93
  end
94
94
 
95
95
  it "displays different text based on users' locale" do
96
- FactoryGirl.create(:phrasing_phrase, locale: 'en', key: 'site.index.intro', value: 'world')
97
- FactoryGirl.create(:phrasing_phrase, locale: 'es', key: 'site.index.intro', value: 'mundo')
96
+ FactoryBot.create(:phrasing_phrase, locale: 'en', key: 'site.index.intro', value: 'world')
97
+ FactoryBot.create(:phrasing_phrase, locale: 'es', key: 'site.index.intro', value: 'mundo')
98
98
 
99
99
  I18n.locale = :en
100
100
  visit root_path
@@ -24,26 +24,12 @@ feature 'edit mode bubble' do
24
24
  find(:css, ".phrasing-edit-all-phrases-link").click
25
25
  expect(current_path).to eq phrasing_phrases_path
26
26
  end
27
-
28
- xit "phrases should have class shouldn't have class phrasable on when edit mode is off", js: true do
29
- edit_mode_checkbox = find(:css, ".onoffswitch-checkbox")
30
- edit_mode_checkbox.click
31
- expect(page.find('.header').first('.phrasable')['class']).to eq 'phrasable'
32
- end
33
-
34
- xit 'edit phrases', js: true do
35
- header_phrase = page.find('.header').first('.phrasable')
36
- header_phrase['class'].should eq 'phrasable phrasable_on'
37
- expect(header_phrase.text).to eq 'The Header'
38
- header_phrase.set "content"
39
- expect(header_phrase.expect.text).to eq 'content'
40
- end
41
27
  end
42
28
 
43
29
  feature "phrasing index" do
44
30
 
45
31
  before do
46
- FactoryGirl.create(:phrasing_phrase, key: "foo", value: "bar")
32
+ FactoryBot.create(:phrasing_phrase, key: "foo", value: "bar")
47
33
  visit phrasing_phrases_path
48
34
  end
49
35
 
@@ -87,23 +73,23 @@ feature "phrasing index" do
87
73
  end
88
74
 
89
75
  it "searches in the middles of strings" do
90
- FactoryGirl.create(:phrasing_phrase, key: "site.index.something")
76
+ FactoryBot.create(:phrasing_phrase, key: "site.index.something")
91
77
  fill_in 'search', with: 'index'
92
78
  click_button 'Search'
93
79
  expect(page).to have_content 'site.index.something'
94
80
  end
95
81
 
96
82
  it "can show all" do
97
- FactoryGirl.create(:phrasing_phrase, key: "foe", value: "beer")
83
+ FactoryBot.create(:phrasing_phrase, key: "foe", value: "beer")
98
84
  click_button 'Search'
99
85
  expect(page).to have_content 'foo'
100
86
  expect(page).to have_content 'foe'
101
87
  end
102
88
 
103
89
  it 'not null values first, global order by key' do
104
- FactoryGirl.create(:phrasing_phrase, key: "foo1", value: nil)
105
- FactoryGirl.create(:phrasing_phrase, key: "foo2", value: "beer")
106
- FactoryGirl.create(:phrasing_phrase, key: "foo3", value: nil)
90
+ FactoryBot.create(:phrasing_phrase, key: "foo1", value: nil)
91
+ FactoryBot.create(:phrasing_phrase, key: "foo2", value: "beer")
92
+ FactoryBot.create(:phrasing_phrase, key: "foo3", value: nil)
107
93
  visit phrasing_phrases_path
108
94
  expect(page.body).to match /foo[\s\S]*foo2[\s\S]*foo1[\s\S]*foo3/
109
95
  end
@@ -112,9 +98,9 @@ feature "phrasing index" do
112
98
 
113
99
  before do
114
100
  PhrasingPhrase.destroy_all
115
- FactoryGirl.create(:phrasing_phrase, key: "foo", value: "bar1", locale: "en")
116
- FactoryGirl.create(:phrasing_phrase, key: "foo", value: "bar2", locale: "fa")
117
- FactoryGirl.create(:phrasing_phrase, key: "foo", value: "bar3", locale: "it")
101
+ FactoryBot.create(:phrasing_phrase, key: "foo", value: "bar1", locale: "en")
102
+ FactoryBot.create(:phrasing_phrase, key: "foo", value: "bar2", locale: "fa")
103
+ FactoryBot.create(:phrasing_phrase, key: "foo", value: "bar3", locale: "it")
118
104
  end
119
105
 
120
106
  it "nil locale, blank search" do
@@ -216,7 +202,7 @@ end
216
202
 
217
203
  feature "phrasing edit" do
218
204
  before do
219
- FactoryGirl.create(:phrasing_phrase, key: "foo", value: "bar")
205
+ FactoryBot.create(:phrasing_phrase, key: "foo", value: "bar")
220
206
  visit phrasing_phrases_path
221
207
  end
222
208
 
@@ -234,7 +220,7 @@ end
234
220
 
235
221
  feature "phrasing update" do
236
222
  before do
237
- FactoryGirl.create(:phrasing_phrase, key: "foo", value: "bar")
223
+ FactoryBot.create(:phrasing_phrase, key: "foo", value: "bar")
238
224
  visit phrasing_phrases_path
239
225
  fill_in 'search', with: 'foo'
240
226
  click_button 'Search'
@@ -257,7 +243,7 @@ end
257
243
 
258
244
  feature 'phrase versions' do
259
245
  before do
260
- phrase = FactoryGirl.create(:phrasing_phrase, key: "foo", value: "bar")
246
+ phrase = FactoryBot.create(:phrasing_phrase, key: "foo", value: "bar")
261
247
  visit edit_phrasing_phrase_path(phrase)
262
248
  end
263
249
 
@@ -299,11 +285,11 @@ feature "downloading and uploading yaml files" do
299
285
  end
300
286
 
301
287
  it "round-trips the YAML" do
302
- FactoryGirl.create(:phrasing_phrase, key: "a.foo1", value: "bar1")
303
- FactoryGirl.create(:phrasing_phrase, key: "a.foo2:", value: "bar2")
304
- FactoryGirl.create(:phrasing_phrase, key: "a.b.foo3", value: "bar3")
305
- FactoryGirl.create(:phrasing_phrase, key: "c.foo4", value: "bar4")
306
- FactoryGirl.create(:phrasing_phrase, key: 2, value: "bar5")
288
+ FactoryBot.create(:phrasing_phrase, key: "a.foo1", value: "bar1")
289
+ FactoryBot.create(:phrasing_phrase, key: "a.foo2:", value: "bar2")
290
+ FactoryBot.create(:phrasing_phrase, key: "a.b.foo3", value: "bar3")
291
+ FactoryBot.create(:phrasing_phrase, key: "c.foo4", value: "bar4")
292
+ FactoryBot.create(:phrasing_phrase, key: 2, value: "bar5")
307
293
  expect(PhrasingPhrase.count).to eq 5
308
294
 
309
295
  visit import_export_phrasing_phrases_path
@@ -332,7 +318,7 @@ feature "downloading and uploading yaml files" do
332
318
 
333
319
  it "round-trips the yaml with complicated text" do
334
320
  value = "“hello world“ üokåa®fgsdf;::fs;kdf"
335
- FactoryGirl.create(:phrasing_phrase, key: "a.foo", value: value)
321
+ FactoryBot.create(:phrasing_phrase, key: "a.foo", value: value)
336
322
 
337
323
  visit import_export_phrasing_phrases_path
338
324
  click_link 'Download as YAML'
@@ -396,8 +382,8 @@ feature "locales" do
396
382
  end
397
383
 
398
384
  it "exports yaml containing multiple locales" do
399
- FactoryGirl.create(:phrasing_phrase, locale: 'en', key: 'hello', value: 'world')
400
- FactoryGirl.create(:phrasing_phrase, locale: 'es', key: 'hello', value: 'mundo')
385
+ FactoryBot.create(:phrasing_phrase, locale: 'en', key: 'hello', value: 'world')
386
+ FactoryBot.create(:phrasing_phrase, locale: 'es', key: 'hello', value: 'mundo')
401
387
 
402
388
  visit download_phrasing_phrases_path
403
389
  yaml = page.source
@@ -90,8 +90,8 @@ describe Phrasing::Serializer do
90
90
  end
91
91
 
92
92
  it 'overrides old values' do
93
- FactoryGirl.create(:phrasing_phrase, key: "site.intro", value: "Go Home")
94
- FactoryGirl.create(:phrasing_phrase, key: "site.outro", value: "Kthnx Bye")
93
+ FactoryBot.create(:phrasing_phrase, key: "site.intro", value: "Go Home")
94
+ FactoryBot.create(:phrasing_phrase, key: "site.outro", value: "Kthnx Bye")
95
95
 
96
96
  expect(english_phrases.where(key: "site.intro").first.value).to eq("Go Home")
97
97
  expect(english_phrases.where(key: "site.outro").first.value).to eq("Kthnx Bye")
@@ -112,8 +112,8 @@ describe Phrasing::Serializer do
112
112
 
113
113
  context 'imports and exports' do
114
114
  it 'without changing, should return 0 number of changes' do
115
- FactoryGirl.create(:phrasing_phrase, key: "site.intro", value: "Go Home")
116
- FactoryGirl.create(:phrasing_phrase, key: "site.outro", value: "Kthnx Bye")
115
+ FactoryBot.create(:phrasing_phrase, key: "site.intro", value: "Go Home")
116
+ FactoryBot.create(:phrasing_phrase, key: "site.outro", value: "Kthnx Bye")
117
117
 
118
118
  expect(english_phrases.where(key: "site.intro").first.value).to eq("Go Home")
119
119
  expect(english_phrases.where(key: "site.outro").first.value).to eq("Kthnx Bye")
@@ -133,8 +133,8 @@ describe Phrasing::Serializer do
133
133
  PhrasingPhrase.destroy_all
134
134
  end
135
135
  it 'flattened phrases' do
136
- FactoryGirl.create(:phrasing_phrase, key: "site.intro", value: "Go Home")
137
- FactoryGirl.create(:phrasing_phrase, key: "site.outro", value: "Kthnx Bye")
136
+ FactoryBot.create(:phrasing_phrase, key: "site.intro", value: "Go Home")
137
+ FactoryBot.create(:phrasing_phrase, key: "site.outro", value: "Kthnx Bye")
138
138
 
139
139
  expect(english_phrases.where(key: "site.intro").first.value).to eq("Go Home")
140
140
  expect(english_phrases.where(key: "site.outro").first.value).to eq("Kthnx Bye")
@@ -146,8 +146,8 @@ describe Phrasing::Serializer do
146
146
  end
147
147
 
148
148
  it 'with different locales' do
149
- FactoryGirl.create(:phrasing_phrase, key: "site.intro", value: "Hello", locale: :en)
150
- FactoryGirl.create(:phrasing_phrase, key: "site.intro", value: "Bonjour", locale: :fr)
149
+ FactoryBot.create(:phrasing_phrase, key: "site.intro", value: "Hello", locale: :en)
150
+ FactoryBot.create(:phrasing_phrase, key: "site.intro", value: "Bonjour", locale: :fr)
151
151
 
152
152
  expect(english_phrases.where(key: "site.intro").first.value).to eq("Hello")
153
153
  expect(french_phrases.where(key: "site.intro").first.value).to eq("Bonjour")
@@ -31,7 +31,7 @@
31
31
  # end
32
32
 
33
33
  # it "returns phrasing_phrase if present" do
34
- # cct = FactoryGirl.create(:phrasing_phrase)
34
+ # cct = FactoryBot.create(:phrasing_phrase)
35
35
  # base.lookup(cct.locale, cct.key).should == cct.value
36
36
  # end
37
37
 
@@ -9,7 +9,7 @@ describe PhrasingPhrase do
9
9
  it 'on #save! should raise errors if the key and locale are the same for two phrases' do
10
10
  PhrasingPhrase.create(key: "foo", locale: "en", value: "bar")
11
11
  new_phrase = PhrasingPhrase.new(key: "foo", locale: "en", value: "bar2")
12
- expect { new_phrase.save! }.to raise_error
12
+ expect { new_phrase.save! }.to raise_error(ActiveRecord::RecordInvalid)
13
13
  end
14
14
 
15
15
  it 'on #save, if the key and locale are the same for two phrases, the latter one should be invalid' do
@@ -29,7 +29,3 @@ describe PhrasingPhrase do
29
29
  end
30
30
 
31
31
  end
32
-
33
-
34
-
35
-
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phrasing
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomislav Car
8
8
  - Damir Svrtan
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-11-05 00:00:00.000000000 Z
12
+ date: 2021-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -132,6 +132,7 @@ files:
132
132
  - lib/phrasing.rb
133
133
  - lib/phrasing/rails/engine.rb
134
134
  - lib/phrasing/serializer.rb
135
+ - lib/phrasing/string.rb
135
136
  - lib/phrasing/version.rb
136
137
  - phrasing.gemspec
137
138
  - spec/controllers/phrasing_phrases_controller.rb
@@ -184,7 +185,7 @@ homepage: http://github.com/infinum/phrasing
184
185
  licenses:
185
186
  - MIT
186
187
  metadata: {}
187
- post_install_message:
188
+ post_install_message:
188
189
  rdoc_options: []
189
190
  require_paths:
190
191
  - lib
@@ -199,9 +200,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
200
  - !ruby/object:Gem::Version
200
201
  version: '0'
201
202
  requirements: []
202
- rubyforge_project:
203
- rubygems_version: 2.6.11
204
- signing_key:
203
+ rubygems_version: 3.2.15
204
+ signing_key:
205
205
  specification_version: 4
206
206
  summary: Edit phrases inline for Rails applications!
207
207
  test_files: []