Permalink
Browse files

Index tables using js 'drag and drop sortable functionality' (i.e. im…

…ages, variants and option_types) must define tbody, if not TRs can be dropped above the THs resulting in ugly views

[fixes #1455]

Merges #1456
  • Loading branch information...
1 parent addc303 commit 97c5176f04a342d485abafcd28989be95337bf71 @joahking joahking committed with radar Apr 27, 2012
@@ -12,6 +12,7 @@
<th><%= t(:action) %></th>
</tr>
+ <tbody>
<% @product.images.each do |image| %>
<tr id="<%= spree_dom_id image %>" data-hook="images_row">
<td>
@@ -46,6 +47,7 @@
</tr>
<% end %>
<% end %>
+ </tbody>
</table>
<div id="images" data-hook></div>
@@ -19,6 +19,7 @@
<th><%= t(:presentation) %></th>
<th></th>
</tr>
+ <tbody>
<% @option_types.each do |option_type| %>
<tr class="spree_option_type" id="<%= spree_dom_id option_type %>" data-hook="option_row">
<td><span class="handle"></span> <%= option_type.name %></td>
@@ -30,4 +31,5 @@
</td>
</tr>
<% end %>
+ </tbody>
</table>
@@ -10,6 +10,7 @@
<th><%= t(:on_hand) %></th>
<th><%= t(:action) %></th>
</tr>
+ <tbody>
<% @variants.each do |variant| %>
<!-- you can skip variant with no options: that's just the default variant that all products have -->
<% next if variant.option_values.empty? %>
@@ -28,6 +29,7 @@
<% unless @product.has_variants? %>
<tr><td colspan="9"><%= t(:none) %></td></tr>
<% end %>
+ </tbody>
</table>
<% if @product.empty_option_values? %>
@@ -11,14 +11,14 @@
visit spree.admin_path
click_link "Products"
- within('table.index tr:nth-child(2)') { click_link "Edit" }
+ click_link "Edit"
click_link "Images"
click_link "new_image_link"
absolute_path = File.expand_path(Rails.root.join('..', '..', 'spec', 'support', 'ror_ringer.jpeg'))
attach_file('image_attachment', absolute_path)
click_button "Update"
page.should have_content("successfully created!")
- within('table.index tr:nth-child(2)') { click_link "Edit" }
+ click_link "Edit"
fill_in "image_alt", :with => "ruby on rails t-shirt"
click_button "Update"
page.should have_content("successfully updated!")
@@ -14,10 +14,12 @@
create(:option_type, :name => "tshirt-size", :presentation => "Size")
click_link "Option Types"
- find('table#listing_option_types tr:nth-child(2) td:nth-child(1)').text.should == " tshirt-color"
- find('table#listing_option_types tr:nth-child(2) td:nth-child(2)').text.should == "Color"
- find('table#listing_option_types tr:nth-child(3) td:nth-child(1)').text.should == " tshirt-size"
- find('table#listing_option_types tr:nth-child(3) td:nth-child(2)').text.should == "Size"
+ within("table#listing_option_types") do
+ page.should have_content("Color")
+ page.should have_content("tshirt-color")
+ page.should have_content("Size")
+ page.should have_content("tshirt-size")
+ end
end
end
@@ -44,7 +46,7 @@
create(:option_type, :name => "tshirt-color", :presentation => "Color")
create(:option_type, :name => "tshirt-size", :presentation => "Size")
click_link "Option Types"
- within('table#listing_option_types tr:nth-child(2)') { click_link "Edit" }
+ within('table#listing_option_types') { click_link "Edit" }
fill_in "option_type_name", :with => "foo-size 99"
click_button "Update"
page.should have_content("successfully updated!")
@@ -174,19 +174,17 @@
it "should allow an admin to upload an image and edit it for a product" do
Spree::Image.attachment_definitions[:attachment].delete :storage
create(:product, :name => 'apache baseball cap', :available_on => '2011-01-01 01:01:01', :sku => "A100")
- create(:product, :name => 'apache baseball cap2', :available_on => '2011-01-01 01:01:01', :sku => "B100")
- create(:product, :name => 'zomg shirt', :available_on => '2011-01-01 01:01:01', :sku => "Z100")
Spree::Product.update_all :count_on_hand => 10
click_link "Products"
- within('table#listing_products tr:nth-child(2)') { click_link "Edit" }
+ within('table#listing_products') { click_link "Edit" }
click_link "Images"
click_link "new_image_link"
absolute_path = File.expand_path(Rails.root.join('..', '..', 'spec', 'support', 'ror_ringer.jpeg'))
attach_file('image_attachment', absolute_path)
click_button "Update"
page.should have_content("successfully created!")
- within('table.index tr:nth-child(2)') { click_link "Edit" }
+ within('table.index') { click_link "Edit" }
fill_in "image_alt", :with => "ruby on rails t-shirt"
click_button "Update"
page.should have_content("successfully updated!")
@@ -197,19 +195,17 @@
context "uploading a product image" do
it "should allow an admin to upload an image and edit it for a product" do
create(:product, :name => 'apache baseball cap', :available_on => '2011-01-01 01:01:01', :sku => "A100")
- create(:product, :name => 'apache baseball cap2', :available_on => '2011-01-01 01:01:01', :sku => "B100")
- create(:product, :name => 'zomg shirt', :available_on => '2011-01-01 01:01:01', :sku => "Z100")
Spree::Product.update_all :count_on_hand => 10
click_link "Products"
- within('table#listing_products tr:nth-child(2)') { click_link "Edit" }
+ within('table#listing_products') { click_link "Edit" }
click_link "Images"
click_link "new_image_link"
absolute_path = File.expand_path(Rails.root.join('..', '..', 'spec', 'support', 'ror_ringer.jpeg'))
attach_file('image_attachment', absolute_path)
click_button "Update"
page.should have_content("successfully created!")
- within('table.index tr:nth-child(2)') { click_link "Edit" }
+ within('table.index') { click_link "Edit" }
fill_in "image_alt", :with => "ruby on rails t-shirt"
click_button "Update"
page.should have_content("successfully updated!")

0 comments on commit 97c5176

Please sign in to comment.