best_in_place 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/best_in_place.gemspec +1 -1
- data/lib/best_in_place/helper.rb +5 -1
- data/lib/best_in_place/version.rb +1 -1
- data/spec/integration/js_spec.rb +21 -30
- data/test_app/Gemfile +3 -3
- data/test_app/app/controllers/users_controller.rb +0 -9
- data/test_app/app/views/users/show.html.erb +1 -1
- metadata +15 -16
data/Gemfile
CHANGED
data/best_in_place.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_dependency "rails", "~> 3.1"
|
23
23
|
s.add_dependency "jquery-rails"
|
24
24
|
|
25
|
-
s.add_development_dependency "rspec-rails", "~> 2.
|
25
|
+
s.add_development_dependency "rspec-rails", "~> 2.8.0"
|
26
26
|
s.add_development_dependency "nokogiri", ">= 1.5.0"
|
27
27
|
s.add_development_dependency "capybara", ">= 1.0.1"
|
28
28
|
end
|
data/lib/best_in_place/helper.rb
CHANGED
@@ -43,7 +43,7 @@ module BestInPlace
|
|
43
43
|
out << " data-type='#{opts[:type]}'"
|
44
44
|
out << " data-inner-class='#{opts[:inner_class]}'" if opts[:inner_class]
|
45
45
|
out << " data-html-attrs='#{opts[:html_attrs].to_json}'" unless opts[:html_attrs].blank?
|
46
|
-
out << " data-original-content='#{object.send(field)}'" if opts[:display_as] || opts[:display_with]
|
46
|
+
out << " data-original-content='#{attribute_escape(object.send(field))}'" if opts[:display_as] || opts[:display_with]
|
47
47
|
if !opts[:sanitize].nil? && !opts[:sanitize]
|
48
48
|
out << " data-sanitize='false'>"
|
49
49
|
out << sanitize(value, :tags => %w(b i u s a strong em p h1 h2 h3 h4 h5 ul li ol hr pre span img br), :attributes => %w(id class href))
|
@@ -80,6 +80,10 @@ module BestInPlace
|
|
80
80
|
object.send(field).to_s.presence || ""
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
def attribute_escape(data)
|
85
|
+
data.to_s.gsub("&", "&").gsub("'", "'") unless data.nil?
|
86
|
+
end
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
data/spec/integration/js_spec.rb
CHANGED
@@ -368,36 +368,6 @@ describe "JS behaviour", :js => true do
|
|
368
368
|
end
|
369
369
|
end
|
370
370
|
|
371
|
-
it "should show validation errors using respond_with in the controller" do
|
372
|
-
@user.save!
|
373
|
-
visit user_path(@user)
|
374
|
-
|
375
|
-
bip_text @user, :last_name, "a"
|
376
|
-
page.should have_content("last_name has invalid length")
|
377
|
-
end
|
378
|
-
|
379
|
-
it "should be able to update a field after an error using respond_with in the controller" do
|
380
|
-
@user.save!
|
381
|
-
visit user_path(@user)
|
382
|
-
|
383
|
-
bip_text @user, :last_name, "a"
|
384
|
-
|
385
|
-
within("#last_name") do
|
386
|
-
page.should have_content("Napoli")
|
387
|
-
end
|
388
|
-
|
389
|
-
bip_text @user, :last_name, "Another"
|
390
|
-
|
391
|
-
within("#last_name") do
|
392
|
-
page.should have_content("Another")
|
393
|
-
end
|
394
|
-
|
395
|
-
visit user_path(@user)
|
396
|
-
within("#last_name") do
|
397
|
-
page.should have_content("Another")
|
398
|
-
end
|
399
|
-
end
|
400
|
-
|
401
371
|
it "should fire off a callback when updating a field" do
|
402
372
|
@user.save!
|
403
373
|
visit user_path(@user)
|
@@ -466,15 +436,32 @@ describe "JS behaviour", :js => true do
|
|
466
436
|
|
467
437
|
bip_text @user, :address, "New address"
|
468
438
|
|
439
|
+
sleep 1
|
440
|
+
|
469
441
|
id = BestInPlace::Utils.build_best_in_place_id @user, :address
|
470
442
|
page.execute_script <<-JS
|
471
443
|
$("##{id}").click();
|
472
444
|
JS
|
473
445
|
|
446
|
+
sleep 1
|
447
|
+
|
474
448
|
text = page.find("##{id} input").value
|
475
449
|
text.should == "New address"
|
476
450
|
end
|
477
451
|
end
|
452
|
+
|
453
|
+
it "should quote properly the data-original-content attribute" do
|
454
|
+
@user.address = "A's & B's"
|
455
|
+
@user.save!
|
456
|
+
retry_on_timeout do
|
457
|
+
visit user_path(@user)
|
458
|
+
|
459
|
+
id = BestInPlace::Utils.build_best_in_place_id @user, :address
|
460
|
+
|
461
|
+
text = page.find("##{id}")["data-original-content"]
|
462
|
+
text.should == "A's & B's"
|
463
|
+
end
|
464
|
+
end
|
478
465
|
end
|
479
466
|
|
480
467
|
describe "display_with" do
|
@@ -534,11 +521,15 @@ describe "JS behaviour", :js => true do
|
|
534
521
|
|
535
522
|
bip_text @user, :money, "40"
|
536
523
|
|
524
|
+
sleep 1
|
525
|
+
|
537
526
|
id = BestInPlace::Utils.build_best_in_place_id @user, :money
|
538
527
|
page.execute_script <<-JS
|
539
528
|
$("##{id}").click();
|
540
529
|
JS
|
541
530
|
|
531
|
+
sleep 1
|
532
|
+
|
542
533
|
text = page.find("##{id} input").value
|
543
534
|
text.should == "40"
|
544
535
|
end
|
data/test_app/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
gem 'rails', '
|
3
|
+
gem 'rails', '3.2'
|
4
4
|
gem 'sqlite3'
|
5
5
|
|
6
6
|
gem 'best_in_place', :path => ".."
|
@@ -10,7 +10,7 @@ gem 'jquery-rails'
|
|
10
10
|
gem 'rdiscount'
|
11
11
|
|
12
12
|
group :assets do
|
13
|
-
gem 'sass-rails', '~> 3.
|
14
|
-
gem 'coffee-rails', '~> 3.
|
13
|
+
gem 'sass-rails', '~> 3.2.3'
|
14
|
+
gem 'coffee-rails', '~> 3.2.1'
|
15
15
|
gem 'uglifier', '>= 1.0.3'
|
16
16
|
end
|
@@ -1,6 +1,4 @@
|
|
1
1
|
class UsersController < ApplicationController
|
2
|
-
respond_to :html, :json
|
3
|
-
|
4
2
|
# GET /users
|
5
3
|
# GET /users.xml
|
6
4
|
def index
|
@@ -88,11 +86,4 @@ class UsersController < ApplicationController
|
|
88
86
|
format.xml { head :ok }
|
89
87
|
end
|
90
88
|
end
|
91
|
-
|
92
|
-
def test_respond_with
|
93
|
-
@user = User.find(params[:id])
|
94
|
-
|
95
|
-
@user.update_attributes(params[:user])
|
96
|
-
respond_with(@user)
|
97
|
-
end
|
98
89
|
end
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<tr>
|
14
14
|
<td>Last Name</td>
|
15
15
|
<td id="last_name">
|
16
|
-
<%= best_in_place @user, :last_name, :nil => "Nothing to show"
|
16
|
+
<%= best_in_place @user, :last_name, :nil => "Nothing to show" %>
|
17
17
|
</td>
|
18
18
|
</tr>
|
19
19
|
<tr>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: best_in_place
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &83802130 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *83802130
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jquery-rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &83801750 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,21 +32,21 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *83801750
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec-rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &83800970 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.
|
43
|
+
version: 2.8.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *83800970
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: nokogiri
|
49
|
-
requirement: &
|
49
|
+
requirement: &83800320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.5.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *83800320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: capybara
|
60
|
-
requirement: &
|
60
|
+
requirement: &83819560 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 1.0.1
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *83819560
|
69
69
|
description: BestInPlace is a jQuery script and a Rails 3 helper that provide the
|
70
70
|
method best_in_place to display any object field easily editable for the user by
|
71
71
|
just clicking on it. It supports input data, text data, boolean data and custom
|
@@ -102,7 +102,6 @@ files:
|
|
102
102
|
- spec/spec_helper.rb
|
103
103
|
- spec/support/retry_on_timeout.rb
|
104
104
|
- test_app/Gemfile
|
105
|
-
- test_app/Gemfile.lock
|
106
105
|
- test_app/README
|
107
106
|
- test_app/Rakefile
|
108
107
|
- test_app/app/assets/images/red_pen.png
|
@@ -192,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
191
|
version: '0'
|
193
192
|
segments:
|
194
193
|
- 0
|
195
|
-
hash: -
|
194
|
+
hash: -802068595
|
196
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
196
|
none: false
|
198
197
|
requirements:
|
@@ -201,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
200
|
version: '0'
|
202
201
|
segments:
|
203
202
|
- 0
|
204
|
-
hash: -
|
203
|
+
hash: -802068595
|
205
204
|
requirements: []
|
206
205
|
rubyforge_project: best_in_place
|
207
206
|
rubygems_version: 1.8.10
|