Sha256: 4d5333f780bcfbbe0f7fd0e6cb2be74000937314d97a924b8f870037d4ed4854

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

require 'test_helper'
require 'netzke-core'

module Netzke::GridPanelExtras; end

require 'netzke/plugins/configuration_tool'
require 'netzke/accordion_panel'

require 'netzke/grid_panel_api'
require 'netzke/grid_panel_js'
require 'netzke/grid_panel'

require 'netzke/active_record/basepack'

class GridPanelTest < ActiveSupport::TestCase
  
  test "api" do
    grid = Netzke::GridPanel.new(:name => 'grid', :data_class_name => 'Book', :layout_manager => false, :columns => [:id, :title, :recent])

    # post
    res = grid.post_data("created_records" => [{:title => 'Lord of the Rings'}].to_nifty_json)
    assert_equal('Lord of the Rings', Book.first.title)

    grid.post_data("updated_records" => [{:id => Book.first.id, :title => 'Lolita'}].to_json)
    assert_equal('Lolita', Book.first.title)

    grid.post_data("created_records" => [{:title => 'Upanishad'}].to_json)
    
    # get
    data = grid.get_data
    assert_equal('Lolita', data[:data][0][1]) # title of the first book
    assert_equal('Yes', data[:data][1][2]) # "recent" virtual column in the second book

    # delete
    res = grid.delete_data(:records => [1,2].to_json)
    assert_equal(nil, Book.first)
    
  end

  
  # TODO: add tests with association column
  
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
skozlov-netzke-basepack-0.5.0 test/unit/grid_panel_test.rb
skozlov-netzke-basepack-0.5.1 test/unit/grid_panel_test.rb
skozlov-netzke-basepack-0.5.2 test/unit/grid_panel_test.rb
netzke-basepack-0.5.4 test/unit/grid_panel_test.rb
netzke-basepack-0.5.3 test/unit/grid_panel_test.rb
netzke-basepack-0.5.1 test/unit/grid_panel_test.rb
netzke-basepack-0.5.2 test/unit/grid_panel_test.rb