best_in_place 3.0.0 → 3.0.1

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.
@@ -18,22 +18,16 @@ describe "Monitor new fields", :js => true do
18
18
  @user.save!
19
19
  visit show_ajax_user_path(@user)
20
20
 
21
- sleep(1) #give time to the ajax request to work
21
+ wait_for_ajax
22
22
 
23
- within("#email") do
24
- expect(page).to have_content("lucianapoli@gmail")
25
- end
23
+ expect(find('#email')).to have_content('lucianapoli@gmail')
26
24
 
27
25
  bip_text @user, :email, "new@email.com"
28
26
 
29
- within("#email") do
30
- expect(page).to have_content("new@email.com")
31
- end
27
+ expect(find('#email')).to have_content('new@email.com')
32
28
 
33
29
  bip_text @user, :email, "new_two@email.com"
34
30
 
35
- within("#email") do
36
- expect(page).to have_content("new_two@email.com")
37
- end
31
+ expect(find('#email')).to have_content('new_two@email.com')
38
32
  end
39
33
  end
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require 'rails_helper'
3
2
 
4
3
  describe "JS behaviour", :js => true do
5
4
  before do
@@ -17,24 +16,20 @@ describe "JS behaviour", :js => true do
17
16
  it "should be able to use bip_text to update a text area" do
18
17
  @user.save!
19
18
  visit user_path(@user)
20
- within("#description") do
21
- expect(page).to have_content("User description")
22
- end
19
+ expect(find('#description')).to have_content('User description')
23
20
 
24
21
  bip_area @user, :description, "A new description"
25
22
 
26
23
  visit user_path(@user)
27
- within("#description") do
28
- expect(page).to have_content("A new description")
29
- end
24
+
25
+ expect(find('#description')).to have_content('A new description')
30
26
  end
31
27
 
32
28
  it "should be able to use a bip_text with :display_with option" do
33
29
  @user.description = "I'm so awesome"
34
30
  @user.save!
35
31
  visit user_path(@user)
36
- within("#dw_description") do
37
- expect(page).to have_content("I'm so awesome")
38
- end
32
+
33
+ expect(find('#dw_description')).to have_content("I'm so awesome")
39
34
  end
40
35
  end
@@ -47,7 +47,7 @@ textarea {
47
47
  }
48
48
  .best_in_place:hover, #user_account .do_hover {
49
49
  padding-right: 1.5em;
50
- background: url(<%= asset_path "red_pen.png" %>) no-repeat right;
50
+ background: url("/assets/red_pen.png") no-repeat right;
51
51
  background-color: #CCC;
52
52
  }
53
53
  .info_edit {
@@ -81,5 +81,5 @@ textarea {
81
81
  width: 25px;
82
82
  height: 25px;
83
83
  text-indent: -9999px;
84
- background: url(<%= image_path("purrClose.png") %>) no-repeat;
84
+ background: url("assets/purrClose.png") no-repeat;
85
85
  }
@@ -14,7 +14,7 @@ class UsersController < ApplicationController
14
14
  # GET /users/1.xml
15
15
  def show
16
16
  @user = User.find(params[:id])
17
- @countries = COUNTRIES
17
+ @countries = COUNTRIES_HASH
18
18
 
19
19
  respond_to do |format|
20
20
  format.html # show.html.erb
@@ -29,12 +29,12 @@ class UsersController < ApplicationController
29
29
 
30
30
  def show_ajax
31
31
  @user = User.find(params[:id])
32
- @countries = COUNTRIES
32
+ @countries = COUNTRIES_HASH
33
33
  end
34
34
 
35
35
  def double_init
36
36
  @user = User.find(params[:id])
37
- @countries = COUNTRIES
37
+ @countries = COUNTRIES_HASH
38
38
  end
39
39
 
40
40
  # GET /users/1/edit
@@ -16,6 +16,9 @@ class User < ActiveRecord::Base
16
16
  validates_numericality_of :money_proc, :allow_blank => true
17
17
 
18
18
  alias_attribute :money_custom, :money
19
+ alias_attribute :money_value, :money
20
+ alias_attribute :receive_email_image, :receive_email
21
+ alias_attribute :description_simple, :description
19
22
 
20
23
  def address_format
21
24
  "<b>addr => [#{address}]</b>".html_safe
@@ -37,7 +37,7 @@
37
37
  </div>
38
38
  <div class="field">
39
39
  <%= f.label :country %><br />
40
- <%= f.select :country, COUNTRIES.map {|c|
40
+ <%= f.select :country, COUNTRIES_HASH.map {|c|
41
41
  v0 = c[0]
42
42
  c[0] = c[1]
43
43
  c[1] = v0
@@ -17,7 +17,7 @@
17
17
  </td>
18
18
  <td><small><a href="#" id="edit_<%= user.id %>">edit</a></small></td>
19
19
  <td><%= user.last_name %></td>
20
- <td><%= COUNTRIES[user.country.to_i] %></td>
20
+ <td><%= COUNTRIES_HASH[user.country.to_i] %></td>
21
21
  </tr>
22
22
  <% end %>
23
23
  </table>
@@ -61,7 +61,7 @@
61
61
  <tr>
62
62
  <td>Receive newsletter (image)?</td>
63
63
  <td id="receive_email_image">
64
- <%= best_in_place @user, :receive_email, as: :checkbox, :collection => {'false' => image_tag('no.png'), 'true' => image_tag('yes.png')} %>
64
+ <%= best_in_place @user, :receive_email_image, as: :checkbox, :collection => {'false' => image_tag('no.png'), 'true' => image_tag('yes.png')} %>
65
65
  </td>
66
66
  </tr>
67
67
  <tr>
@@ -96,7 +96,7 @@
96
96
  <tr>
97
97
  <td>Simple-formatted user description</td>
98
98
  <td id="dw_description">
99
- <%= best_in_place @user, :description, :display_with => :simple_format, as: :textarea %>
99
+ <%= best_in_place @user, :description_simple, :display_with => :simple_format, as: :textarea %>
100
100
  </td>
101
101
  </tr>
102
102
  <tr>
@@ -120,7 +120,7 @@
120
120
  <tr>
121
121
  <td>Money with value</td>
122
122
  <td id="money_value">
123
- <%= best_in_place @user, :money, :display_with => :number_to_currency, value: 'Custom Value' %>
123
+ <%= best_in_place @user, :money_value, :display_with => :number_to_currency, value: 'Custom Value' %>
124
124
  </td>
125
125
  </tr>
126
126
  <tr>
@@ -1 +1,5 @@
1
- COUNTRIES = { 1 => "Spain", 2 => "Italy", 3 => "Germany", 4 => "France" }
1
+ COUNTRIES_HASH = { 1 => 'Spain', 2 => 'Italy', 3 => 'Germany', 4 => 'France' }
2
+ COUNTRIES_HASH_STRING_KEYS = { es: 'Spain', it: 'Italy', de: 'Germany', fr: 'France' }
3
+ COUNTRIES_ARRAY = %w(Spain Italy Germany France)
4
+ COUNTRIES_APOSTROPHE_HASH = {1 => "Joe's Country", 2 => "Bob's Country"}
5
+ COUNTRIES_APOSTROPHE_ARRAY = ["Joe's Country", "Bob's Country"]
data/spec/rails_helper.rb CHANGED
@@ -2,6 +2,14 @@ ENV['RAILS_ENV'] ||= 'test'
2
2
 
3
3
  require 'combustion'
4
4
  require 'capybara/rspec'
5
+
6
+ require 'capybara/poltergeist'
7
+ require_relative 'support/screenshot'
8
+ Capybara.register_driver :poltergeist do |app|
9
+ Capybara::Poltergeist::Driver.new(app, {js_errors: false, inspector: true})
10
+ end
11
+ Capybara.javascript_driver = :poltergeist
12
+
5
13
  require 'best_in_place'
6
14
 
7
15
  Combustion.initialize! :active_record, :action_controller,
@@ -0,0 +1,7 @@
1
+ def screenshot
2
+ path = Rails.root.join("local", "screenshot.png")
3
+ File.delete(path) if File.exists?(path)
4
+
5
+ save_screenshot(path, full: true)
6
+ Launchy.open(path.to_s)
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: best_in_place
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernat Farrero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-19 00:00:00.000000000 Z
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -104,7 +104,7 @@ files:
104
104
  - spec/internal/app/assets/stylesheets/.gitkeep
105
105
  - spec/internal/app/assets/stylesheets/jquery-ui-1.8.16.custom.css.erb
106
106
  - spec/internal/app/assets/stylesheets/scaffold.css
107
- - spec/internal/app/assets/stylesheets/style.css.erb
107
+ - spec/internal/app/assets/stylesheets/style.css
108
108
  - spec/internal/app/controllers/admin/users_controller.rb
109
109
  - spec/internal/app/controllers/application_controller.rb
110
110
  - spec/internal/app/controllers/cuca/cars_controller.rb
@@ -133,6 +133,7 @@ files:
133
133
  - spec/internal/public/favicon.ico
134
134
  - spec/rails_helper.rb
135
135
  - spec/support/retry_on_timeout.rb
136
+ - spec/support/screenshot.rb
136
137
  - spec/utils_spec.rb
137
138
  - vendor/assets/javascripts/jquery.autosize.js
138
139
  - vendor/assets/javascripts/jquery.purr.js
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  version: '0'
156
157
  requirements: []
157
158
  rubyforge_project:
158
- rubygems_version: 2.4.2
159
+ rubygems_version: 2.2.2
159
160
  signing_key:
160
161
  specification_version: 4
161
162
  summary: It makes any field in place editable by clicking on it, it works for inputs,