require "test_helper" class Admin::TableHelperTest < ActiveSupport::TestCase include Admin::TableHelper include ActionView::Helpers::UrlHelper include ActionView::Helpers::TagHelper include ActionView::Helpers::TextHelper def render(*args); args; end def raw(*args); args; end setup do default_url_options[:host] = "test.host" end =begin # FIXME def test_build_table @current_user = Factory(:typus_user) params = { :controller => 'admin/typus_users', :action => 'index' } self.expects(:params).at_least_once.returns(params) fields = TypusUser.typus_fields_for(:list) items = TypusUser.find(:all) expects(:render).once.with('admin/helpers/table_header', { :headers => [ 'Email ', 'Role ', 'Status ', ' ', ' ' ]}) build_table(TypusUser, fields, items) end =end =begin def test_table_header @current_user = mock() @current_user.expects(:can?).with("delete", TypusUser).returns(true) fields = TypusUser.typus_fields_for(:list) params = { :controller => "admin/typus_users", :action => "index" } self.expects(:params).at_least_once.returns(params) output = table_header(TypusUser, fields) expected = [ "admin/helpers/table_header", { :headers=> [ %(Email), %(Role), %(Status), " "] } ] assert_equal expected, output end =end =begin def test_table_header_with_params @current_user = mock() @current_user.expects(:can?).with("delete", TypusUser).returns(true) fields = TypusUser.typus_fields_for(:list) params = { :controller => "admin/typus_users", :action => "index", :search => "admin" } self.expects(:params).at_least_once.returns(params) output = table_header(TypusUser, fields) expected = [ "admin/helpers/table_header", { :headers => [ %(Email), %(Role), %(Status), %( ) ] } ] assert_equal expected, output end =end =begin def test_table_header_when_user_cannot_delete_items @current_user = mock() @current_user.expects(:can?).with("delete", TypusUser).returns(false) fields = TypusUser.typus_fields_for(:list) params = { :controller => "admin/typus_users", :action => "index" } self.expects(:params).at_least_once.returns(params) output = table_header(TypusUser, fields) expected = [ "admin/helpers/table_header", { :headers => [ %(Email), %(Role), %(Status) ] } ] assert_equal expected, output end =end =begin def test_table_header_when_user_cannot_delete_items_with_params @current_user = mock() @current_user.expects(:can?).with("delete", TypusUser).returns(false) fields = TypusUser.typus_fields_for(:list) params = { :controller => "admin/typus_users", :action => "index", :search => "admin" } self.expects(:params).at_least_once.returns(params) output = table_header(TypusUser, fields) expected = [ "admin/helpers/table_header", { :headers => [ %(Email), %(Role), %(Status) ] } ] assert_equal expected, output end =end =begin def test_table_belongs_to_field @current_user = Factory(:typus_user) comment = comments(:without_post_id) output = table_belongs_to_field("post", comment) expected = "