Skip to content

Commit

Permalink
Added a failing spec to show the double initialization bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger Campos committed Oct 24, 2011
1 parent 8841d94 commit 6a0ebdb
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/integration/double_init_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# encoding: utf-8
require "spec_helper"

describe "Double initialization bug", :js => true do
before do
@user = User.new :name => "Lucia",
:last_name => "Napoli",
:email => "lucianapoli@gmail.com",
:address => "Via Roma 99",
:zip => "25123",
:country => "2",
:receive_email => false,
: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."
end

it "should be able to change a boolean value" do
@user.save!
visit double_init_user_path(@user)

within("#receive_email") do
page.should have_content("No thanks")
end

bip_bool :user, :receive_email

visit double_init_user_path(@user)
within("#receive_email") do
page.should have_content("Yes of course")
end

end
end
5 changes: 5 additions & 0 deletions test_app/app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def show
end
end

def double_init
@user = User.find(params[:id])
@countries = COUNTRIES.to_a
end

# GET /users/new
# GET /users/new.xml
def new
Expand Down
65 changes: 65 additions & 0 deletions test_app/app/views/users/double_init.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<p>This is a page that initializes best in place two times with testing purposes</p>
<div id="user_account">
<h1>User details</h1>
<%= link_to "Go back to USERS", users_path %>
<p style="margin-left:48em">Click to edit</p>
<table>
<tr>
<td>Name <a id="editme" href="#">(edit me)</a></td>
<td id="name">
<%= best_in_place @user, :name, :type => :input, :activator => "#editme" %>
</td>
</tr>
<tr>
<td>Last Name</td>
<td id="last_name">
<%= best_in_place @user, :last_name, :nil => "Nothing to show", :path => test_respond_with_user_path(@user) %>
</td>
</tr>
<tr>
<td>Email</td>
<td id="email">
<%= best_in_place @user, :email %>
</td>
</tr>
<tr>
<td>Address</td>
<td id="address">
<%= best_in_place @user, :address %>
</td>
</tr>
<tr>
<td>ZIP</td>
<td id="zip">
<%= best_in_place @user, :zip %>
</td>
</tr>
<tr>
<td>Country</td>
<td id="country">
<%= best_in_place @user, :country, :type => :select, :collection => @countries %>
</td>
</tr>
<tr>
<td>Receive newsletter?</td>
<td id="receive_email">
<%= best_in_place @user, :receive_email, :type => :checkbox, :collection => ["No thanks", "Yes of course"] %>
</td>
</tr>
<tr>
<td>User description</td>
<td id="description">
<%= best_in_place @user, :description, :type => :textarea, :sanitize => false %>
</td>
</table>
<br />
<hr />

</div>

<%= javascript_tag do %>
$(document).ready(function() {
/* Activating Best In Place */
jQuery(".best_in_place").best_in_place();
});
<% end %>
1 change: 1 addition & 0 deletions test_app/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resources :users do
member do
put :test_respond_with
get :double_init
end
end

Expand Down

0 comments on commit 6a0ebdb

Please sign in to comment.