best_in_place_mongoid 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe "Double initialization bug", :js => true do
5
+ before do
6
+ @user = User.new :name => "Lucia",
7
+ :last_name => "Napoli",
8
+ :email => "lucianapoli@gmail.com",
9
+ :address => "Via Roma 99",
10
+ :zip => "25123",
11
+ :country => "2",
12
+ :receive_email => false,
13
+ :description => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus a lectus et lacus ultrices auctor. Morbi aliquet convallis tincidunt. Praesent enim libero, iaculis at commodo nec, fermentum a dolor. Quisque eget eros id felis lacinia faucibus feugiat et ante. Aenean justo nisi, aliquam vel egestas vel, porta in ligula. Etiam molestie, lacus eget tincidunt accumsan, elit justo rhoncus urna, nec pretium neque mi et lorem. Aliquam posuere, dolor quis pulvinar luctus, felis dolor tincidunt leo, eget pretium orci purus ac nibh. Ut enim sem, suscipit ac elementum vitae, sodales vel sem."
14
+ end
15
+
16
+ it "should be able to change a boolean value" do
17
+ @user.save!
18
+ visit double_init_user_path(@user)
19
+
20
+ within("#receive_email") do
21
+ page.should have_content("No thanks")
22
+ end
23
+
24
+ bip_bool @user, :receive_email
25
+
26
+ visit double_init_user_path(@user)
27
+ within("#receive_email") do
28
+ page.should have_content("Yes of course")
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,165 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe "JS behaviour", :js => true do
5
+ before do
6
+ @user = User.new :name => "Lucia",
7
+ :last_name => "Napoli",
8
+ :email => "lucianapoli@gmail.com",
9
+ :address => "Via Roma 99",
10
+ :zip => "25123",
11
+ :country => "2",
12
+ :receive_email => false,
13
+ :description => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus a lectus et lacus ultrices auctor. Morbi aliquet convallis tincidunt. Praesent enim libero, iaculis at commodo nec, fermentum a dolor. Quisque eget eros id felis lacinia faucibus feugiat et ante. Aenean justo nisi, aliquam vel egestas vel, porta in ligula. Etiam molestie, lacus eget tincidunt accumsan, elit justo rhoncus urna, nec pretium neque mi et lorem. Aliquam posuere, dolor quis pulvinar luctus, felis dolor tincidunt leo, eget pretium orci purus ac nibh. Ut enim sem, suscipit ac elementum vitae, sodales vel sem."
14
+ end
15
+
16
+ describe "nil option" do
17
+ it "should render the default '-' string when the field is empty" do
18
+ @user.name = ""
19
+ @user.save :validate => false
20
+ visit user_path(@user)
21
+
22
+ within("#name") do
23
+ page.should have_content("-")
24
+ end
25
+ end
26
+
27
+ it "should render the passed nil value if the field is empty" do
28
+ @user.last_name = ""
29
+ @user.save :validate => false
30
+ visit user_path(@user)
31
+
32
+ within("#last_name") do
33
+ page.should have_content("Nothing to show")
34
+ end
35
+ end
36
+ end
37
+
38
+ it "should be able to use bip_text to update a text field" do
39
+ @user.save!
40
+ visit user_path(@user)
41
+ within("#email") do
42
+ page.should have_content("lucianapoli@gmail.com")
43
+ end
44
+
45
+ bip_text @user, :email, "new@email.com"
46
+
47
+ visit user_path(@user)
48
+ within("#email") do
49
+ page.should have_content("new@email.com")
50
+ end
51
+ end
52
+
53
+ it "should be able to update a field two consecutive times" do
54
+ @user.save!
55
+ visit user_path(@user)
56
+
57
+ bip_text @user, :email, "new@email.com"
58
+
59
+ within("#email") do
60
+ page.should have_content("new@email.com")
61
+ end
62
+
63
+ bip_text @user, :email, "new_two@email.com"
64
+
65
+ within("#email") do
66
+ page.should have_content("new_two@email.com")
67
+ end
68
+
69
+ visit user_path(@user)
70
+ within("#email") do
71
+ page.should have_content("new_two@email.com")
72
+ end
73
+ end
74
+
75
+ it "should be able to update a field after an error" do
76
+ @user.save!
77
+ visit user_path(@user)
78
+
79
+ bip_text @user, :email, "wrong format"
80
+ page.should have_content("Email has wrong email format")
81
+
82
+ bip_text @user, :email, "another@email.com"
83
+ within("#email") do
84
+ page.should have_content("another@email.com")
85
+ end
86
+
87
+ visit user_path(@user)
88
+ within("#email") do
89
+ page.should have_content("another@email.com")
90
+ end
91
+ end
92
+
93
+ it "should be able to use bil_select to change a select field" do
94
+ @user.save!
95
+ visit user_path(@user)
96
+ within("#country") do
97
+ page.should have_content("Italy")
98
+ end
99
+
100
+ bip_select @user, :country, "France"
101
+
102
+ visit user_path(@user)
103
+ within("#country") do
104
+ page.should have_content("France")
105
+ end
106
+ end
107
+
108
+ it "should be able to use bip_bool to change a boolean value" do
109
+ @user.save!
110
+ visit user_path(@user)
111
+
112
+ within("#receive_email") do
113
+ page.should have_content("No thanks")
114
+ end
115
+
116
+ bip_bool @user, :receive_email
117
+
118
+ visit user_path(@user)
119
+ within("#receive_email") do
120
+ page.should have_content("Yes of course")
121
+ end
122
+ end
123
+
124
+ it "should show validation errors" do
125
+ @user.save!
126
+ visit user_path(@user)
127
+
128
+ bip_text @user, :address, ""
129
+ page.should have_content("Address can't be blank")
130
+ within("#address") do
131
+ page.should have_content("Via Roma 99")
132
+ end
133
+ end
134
+
135
+ it "should show validation errors using respond_with in the controller" do
136
+ @user.save!
137
+ visit user_path(@user)
138
+
139
+ bip_text @user, :last_name, "a"
140
+ page.should have_content("last_name has invalid length")
141
+ end
142
+
143
+ it "should be able to update a field after an error using respond_with in the controller" do
144
+ @user.save!
145
+ visit user_path(@user)
146
+
147
+ bip_text @user, :last_name, "a"
148
+
149
+ within("#last_name") do
150
+ page.should have_content("Napoli")
151
+ end
152
+
153
+ bip_text @user, :last_name, "Another"
154
+
155
+ within("#last_name") do
156
+ page.should have_content("Another")
157
+ end
158
+
159
+ visit user_path(@user)
160
+ within("#last_name") do
161
+ page.should have_content("Another")
162
+ end
163
+ end
164
+ end
165
+
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe "JS behaviour", :js => true do
5
+ before do
6
+ @user = User.new :name => "Lucia",
7
+ :last_name => "Napoli",
8
+ :email => "lucianapoli@gmail.com",
9
+ :address => "Via Roma 99",
10
+ :zip => "25123",
11
+ :country => "2",
12
+ :receive_email => false,
13
+ :description => "User description"
14
+ end
15
+
16
+ it "should be able to use bip_text to update a text area" do
17
+ @user.save!
18
+ visit user_path(@user)
19
+ within("#description") do
20
+ page.should have_content("User description")
21
+ end
22
+
23
+ bip_area @user, :description, "A new description"
24
+
25
+ visit user_path(@user)
26
+ within("#description") do
27
+ page.should have_content("A new description")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ # Configure Rails Envinronment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path('../../test_app/config/environment', __FILE__)
5
+ require "rspec/rails"
6
+ require "nokogiri"
7
+
8
+ # Load support files
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each{|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ # Remove this line if you don't want RSpec's should and should_not
13
+ # methods or matchers
14
+ require 'rspec/expectations'
15
+
16
+ config.include RSpec::Matchers
17
+ config.include BestInPlaceMongoid::TestHelpers
18
+
19
+ # == Mock Framework
20
+ config.mock_with :rspec
21
+ end
22
+
23
+ Capybara.default_wait_time = 5
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: best_in_place_mongoid
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 2
10
+ version: 1.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Bernat Farrero
14
+ - "Bart\xC5\x82omiej Danek"
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-11-15 00:00:00 +01:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: rails
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 3
33
+ - 1
34
+ - 0
35
+ version: 3.1.0
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: mongoid
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ hash: 5
47
+ segments:
48
+ - 2
49
+ - 3
50
+ - 3
51
+ version: 2.3.3
52
+ type: :runtime
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: jquery-rails
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ type: :runtime
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: rspec-rails
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 19
77
+ segments:
78
+ - 2
79
+ - 7
80
+ - 0
81
+ version: 2.7.0
82
+ type: :development
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: nokogiri
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 1
95
+ - 5
96
+ - 0
97
+ version: 1.5.0
98
+ type: :development
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ name: capybara
102
+ prerelease: false
103
+ requirement: &id006 !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 21
109
+ segments:
110
+ - 1
111
+ - 0
112
+ - 1
113
+ version: 1.0.1
114
+ type: :development
115
+ version_requirements: *id006
116
+ description: BestInPlaceMongoid is a fork of BestInPlace jQuery script and a Rails 3 helper that provide the method best_in_place to display any object field easily editable for the user by just clicking on it. It supports input data, text data, boolean data and custom dropdown data. It works with RESTful controllers.
117
+ email:
118
+ - bernat@itnig.net
119
+ - bartek.danek@gmail.com
120
+ executables: []
121
+
122
+ extensions: []
123
+
124
+ extra_rdoc_files: []
125
+
126
+ files:
127
+ - .gitignore
128
+ - .rspec
129
+ - Gemfile
130
+ - README.md
131
+ - Rakefile
132
+ - best_in_place_mongoid.gemspec
133
+ - lib/assets/javascripts/best_in_place.js
134
+ - lib/assets/javascripts/jquery.purr.js
135
+ - lib/best_in_place_mongoid.rb
136
+ - lib/best_in_place_mongoid/engine.rb
137
+ - lib/best_in_place_mongoid/helper.rb
138
+ - lib/best_in_place_mongoid/test_helpers.rb
139
+ - lib/best_in_place_mongoid/utils.rb
140
+ - lib/best_in_place_mongoid/version.rb
141
+ - spec/helpers/best_in_place_mongoid_spec.rb
142
+ - spec/integration/double_init_spec.rb
143
+ - spec/integration/js_spec.rb
144
+ - spec/integration/text_area_spec.rb
145
+ - spec/spec_helper.rb
146
+ has_rdoc: true
147
+ homepage: http://github.com/bartekd/best_in_place_mongoid
148
+ licenses: []
149
+
150
+ post_install_message:
151
+ rdoc_options: []
152
+
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ hash: 3
161
+ segments:
162
+ - 0
163
+ version: "0"
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ hash: 3
170
+ segments:
171
+ - 0
172
+ version: "0"
173
+ requirements: []
174
+
175
+ rubyforge_project:
176
+ rubygems_version: 1.5.3
177
+ signing_key:
178
+ specification_version: 3
179
+ summary: It makes any field in place editable by clicking on it, it works for inputs, textareas, select dropdowns and checkboxes
180
+ test_files: []
181
+