diff --git a/lib/tabulatr/data/dsl.rb b/lib/tabulatr/data/dsl.rb index 2aca83a..efd6a5c 100644 --- a/lib/tabulatr/data/dsl.rb +++ b/lib/tabulatr/data/dsl.rb @@ -80,7 +80,7 @@ def buttons(opts = {}, &block) output = ->(r) { tdbb = Tabulatr::Data::ButtonBuilder.new self.instance_exec tdbb, r, &block - self.controller.render_to_string partial: '/tabulatr/tabulatr_buttons', locals: {buttons: tdbb.val}, formats: [:html] + self.controller.render_to_string partial: '/tabulatr/bs3/tabulatr_buttons', locals: {buttons: tdbb.val}, formats: [:html] } opts = {header: opts[:header] || '', filter: false, sortable: false}.merge(opts) table_column = Tabulatr::Renderer::Buttons.from( diff --git a/spec/controller/application_controller_spec.rb b/spec/controller/application_controller_spec.rb index e07d4be..c338a5f 100644 --- a/spec/controller/application_controller_spec.rb +++ b/spec/controller/application_controller_spec.rb @@ -23,6 +23,7 @@ def current_user expect_any_instance_of(Tabulatr::Data).to receive(:data_for_table).with( {"pagesize"=>"20", "arguments"=>"products:title", "controller"=>"anonymous", "action"=>"index"}, + {:default_order=>nil}, {:locals=>{current_user: "Han Solo"}, controller: controller} ).and_return(fake_response) expect(fake_response).to receive(:to_tabulatr_json).and_return({}) diff --git a/spec/features/tabulatrs_spec.rb b/spec/features/tabulatrs_spec.rb index ddff822..81a2be3 100644 --- a/spec/features/tabulatrs_spec.rb +++ b/spec/features/tabulatrs_spec.rb @@ -12,11 +12,11 @@ "officia", "deserunt", "mollit", "anim", "est", "laborum"] before(:each) do - @vendor1 = Vendor.create!(:name => "ven d'or", :active => true) - @vendor2 = Vendor.create!(:name => 'producer', :active => true) - @tag1 = Tag.create!(:title => 'foo') - @tag2 = Tag.create!(:title => 'bar') - @tag3 = Tag.create!(:title => 'fubar') + @vendor1 = Vendor.create!(name: "ven d'or", active: true) + @vendor2 = Vendor.create!(name: 'producer', active: true) + @tag1 = Tag.create!(title: 'foo') + @tag2 = Tag.create!(title: 'bar') + @tag3 = Tag.create!(title: 'fubar') end feature "General data" do @@ -37,10 +37,11 @@ end scenario "contains the actual data", js: true do - product = Product.create!(:title => names[0], :active => true, :price => 10.0) + product = Product.create!(title: names[0], active: true, price: 10.0) product.vendor = @vendor1 product.save! visit simple_index_products_path + wait_for_ajax expect(page).to have_content("true") expect(page).to have_content("10.0") expect(product.vendor.name).to eq("ven d'or") @@ -49,7 +50,7 @@ end scenario "correctly contains the association data", js: true do - product = Product.create!(:title => names[0], :active => true, :price => 10.0) + product = Product.create!(title: names[0], active: true, price: 10.0) [@tag1, @tag2, @tag3].each_with_index do |tag, i| product.tags << tag product.save @@ -60,8 +61,8 @@ scenario "contains the actual data multiple times", js: true do 9.times do |i| - product = Product.create!(:title => names[i], :active => i.even?, :price => 11.0+i, - :vendor => i.even? ? @vendor1 : @vendor2) + product = Product.create!(title: names[i], active: i.even?, price: 11.0+i, + vendor: i.even? ? @vendor1 : @vendor2) visit simple_index_products_path expect(page).to have_content(names[i]) expect(page).to have_content((11.0+i).to_s) @@ -70,8 +71,8 @@ scenario "contains the further data on the further pages" do names[10..-1].each_with_index do |n,i| - product = Product.create!(:title => n, :active => i.even?, :price => 20.0+i, - :vendor => i.even? ? @vendor1 : @vendor2) + product = Product.create!(title: n, active: i.even?, price: 20.0+i, + vendor: i.even? ? @vendor1 : @vendor2) visit simple_index_products_path expect(page).to have_no_content(/\s+#{n}\s+/) expect(page).to have_no_content((30.0+i).to_s) @@ -81,7 +82,7 @@ feature 'has_many' do scenario 'displays the count when called with :count', js: true do - product = Product.create!(:title => names[0], :active => true, :price => 10.0) + product = Product.create!(title: names[0], active: true, price: 10.0) [@tag1, @tag2, @tag3].each do |tag| product.tags << tag end @@ -97,7 +98,7 @@ context 'pagination setting is true' do scenario 'has pages', js: true do 5.times do |i| - Product.create!(:title => "test #{i}") + Product.create!(title: "test #{i}") end visit one_item_per_page_with_pagination_products_path expect(page).to have_css('.pagination li a[data-page]', count: 5) @@ -126,7 +127,7 @@ feature "Filters" do scenario "filters with like", js: true do names.each do |n| - Product.create!(:title => n, :active => true, :price => 10.0) + Product.create!(title: n, active: true, price: 10.0) end visit simple_index_products_path click_link 'Filter' @@ -136,7 +137,7 @@ expect(page).to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'dolore') within(".tabulatr_filter_form") do - fill_in("product_filter[products:title][like]", :with => "loreem") + fill_in("product_filter[products:title][like]", with: "loreem") end expect(page).not_to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'lorem') expect(page).not_to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'labore') @@ -165,18 +166,18 @@ click_link 'Filter' within('.tabulatr_filter_form') do - fill_in("product_filter[products:price][from]", :with => 4) + fill_in("product_filter[products:price][from]", with: 4) wait_for_ajax - fill_in("product_filter[products:price][to]", :with => 10) + fill_in("product_filter[products:price][to]", with: 10) wait_for_ajax end expect(page).to have_no_css('.tabulatr-spinner-box') expect(page).to have_css(".tabulatr_table tbody tr", text: 'foo') expect(page).to have_no_css(".tabulatr_table tbody tr", text: 'bar') within('.tabulatr_filter_form') do - fill_in("product_filter[products:price][from]", :with => 12) + fill_in("product_filter[products:price][from]", with: 12) wait_for_ajax - fill_in("product_filter[products:price][to]", :with => 19) + fill_in("product_filter[products:price][to]", with: 19) wait_for_ajax end expect(page).to have_no_css('.tabulatr-spinner-box') @@ -289,7 +290,7 @@ scenario "contains the actual data", js: false do names.shuffle.each.with_index do |n,i| - p = Product.new(:title => n, :active => true, :price => 10.0 + i) + p = Product.new(title: n, active: true, price: 10.0 + i) p.vendor = [@vendor1, @vendor2].shuffle.first p.tags = [@tag1, @tag2, @tag3].shuffle[0..rand(3)] p.save! @@ -323,9 +324,9 @@ scenario 'executes the action when clicked' do - product1 = Product.create!(:title => names[0], :active => true, :price => 10.0) - product2 = Product.create!(:title => names[1], :active => true, :price => 10.0) - product3 = Product.create!(:title => names[2], :active => true, :price => 10.0) + product1 = Product.create!(title: names[0], active: true, price: 10.0) + product2 = Product.create!(title: names[1], active: true, price: 10.0) + product3 = Product.create!(title: names[2], active: true, price: 10.0) visit with_batch_actions_products_path expect(page).to have_css(".tabulatr_table tbody tr", count: 3) find(".tabulatr-checkbox[value='#{product1.id}']").trigger('click') @@ -338,9 +339,9 @@ end scenario 'executes the action for all items if nothing selected' do - product1 = Product.create!(:title => names[0], :active => true, :price => 10.0) - product2 = Product.create!(:title => names[1], :active => true, :price => 10.0) - product3 = Product.create!(:title => names[2], :active => false, :price => 10.0) + product1 = Product.create!(title: names[0], active: true, price: 10.0) + product2 = Product.create!(title: names[1], active: true, price: 10.0) + product3 = Product.create!(title: names[2], active: false, price: 10.0) visit with_batch_actions_products_path find('.tabulatr-batch-actions-menu-wrapper a').click within('.dropdown.open') do @@ -352,7 +353,7 @@ feature "Column options", js: true do scenario 'applys the given style' do - p = Product.create!(:title => names[0], :active => true, :price => 10.0) + p = Product.create!(title: names[0], active: true, price: 10.0) visit with_styling_products_path cell = find(".tabulatr_table tbody td[data-tabulatr-column-name='products:title']") header = find(".tabulatr_table thead th[data-tabulatr-column-name='products:title']") diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 3e39f47..e1f593d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -13,6 +13,7 @@ require 'spec_helper' Capybara.javascript_driver = :poltergeist +Capybara.server = :webrick Capybara.register_driver :poltergeist do |app| Capybara::Poltergeist::Driver.new(app, {js_errors: true}) @@ -25,4 +26,4 @@ RSpec.configure do |config| config.use_transactional_fixtures = false -end \ No newline at end of file +end