Sha256: 4537bd57b990feca7c6968aa1634f3c7777e616e5fd53f83e2b1ce21d508d91e

Contents?: true

Size: 1.79 KB

Versions: 4

Compression:

Stored size: 1.79 KB

Contents

require 'test_helper'

class ActsAsPlacementTest < ActiveSupport::TestCase
	def epom_field(field)
		Placement.epom_fields.key(field)
	end

	test 'fancy_method' do
	  	assert_raises NoMethodError do Placement.fancy_method end
	end

	test 'save an placement' do
		unless EpomRails.config.offline
			placement = placements(:one)	  	

	  	assert	placement.save
	  	assert_instance_of Fixnum, placement.send(epom_field('id'))

	  	# testing save_placement
	  	epom_response = Epom::Placement.get_placement_summary({}, {:placementIds => placement.send(epom_field('id'))})
	  	assert_instance_of Array, epom_response
	  	epom_placement = epom_response.find{|a| a['id'] == placement.send(epom_field('id'))}
	  	assert_equal placement.send(epom_field('name')), epom_placement['name']

	  	# # testing update_placement
	  	assert placement.update name: 'otro string'
	  	epom_response = Epom::Placement.get_placement_summary({}, {:placementIds => placement.send(epom_field('id'))})
	  	assert_instance_of Array, epom_response
	  	epom_placement = epom_response.find{|a| a['id'] == placement.send(epom_field('id'))}
	  	assert_equal placement.send(epom_field('name')), epom_placement['name']
	  end
	end

	test 'delete an placement' do
		unless EpomRails.config.offline
			placement = placements(:one)	  	

	  	assert	placement.save
	  	assert_instance_of Fixnum, placement.send(epom_field('id'))

	  	epom_id = placement.send(epom_field('id'))
	  	assert placement.destroy
	  end
	end

	test 'epom methods' do
		unless EpomRails.config.offline
			placement = placements(:one)	  	

	  	assert	placement.save
	  	assert_instance_of Fixnum, placement.send(epom_field('id'))

			epom_response = Epom::Placement.get_placement_summary({}, {:placementIds => placement.send(epom_field('id'))})
	  	assert_instance_of Array, epom_response
	  end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
epom_rails-0.4.9 test/epom_rails/acts_as_placement_test.rb
epom_rails-0.4.8 test/epom_rails/acts_as_placement_test.rb
epom_rails-0.4.7 test/epom_rails/acts_as_placement_test.rb
epom_rails-0.4.6 test/epom_rails/acts_as_placement_test.rb