ref: master
plugins/event/test/functional/event_block_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
require 'test_helper' class HomeControllerTest < ActionController::TestCase def setup @env = Environment.default @env.enable_plugin('EventPlugin') @p1 = fast_create(Person, :environment_id => @env.id) @e1a = Event.create!(:name=>'Event p1 A', :profile =>@p1) box = Box.create!(:owner => @env) @block = EventPlugin::EventBlock.create!(:box => box) end # Event item CSS selector ev = '.event-plugin_event-block ul.events li.event[itemscope]' + '[itemtype="http://data-vocabulary.org/Event"] ' should 'see events microdata sturcture' do get :index #raise response.body.inspect assert_select '.event-plugin_event-block ul.events' assert_select ev assert_select ev + 'a[itemprop="url"]' assert_select ev + 'time.date[itemprop="startDate"][datetime]' assert_select ev + 'time.date .day' assert_select ev + 'time.date .month' assert_select ev + 'time.date .year' assert_select ev + '.title[itemprop="summary"]' assert_select ev + '.address[itemprop="location"] *[itemprop="name"]' assert_select ev + '.days-left' end should 'see event duration' do @e1a.slug = 'event1a' @e1a.start_date = DateTime.now @e1a.end_date = DateTime.now + 1.day @e1a.save! get :index assert_select ev + 'time.duration[itemprop="endDate"]', /2 days/ @e1a.slug = 'event1a' @e1a.start_date = DateTime.now @e1a.end_date = DateTime.now + 2.day @e1a.save! get :index assert_select ev + 'time.duration[itemprop="endDate"]', /3 days/ end should 'not see event duration for one day events' do get :index assert_select ev + 'time.duration[itemprop="endDate"]', false @e1a.slug = 'event1a' @e1a.start_date = DateTime.now @e1a.end_date = DateTime.now @e1a.save! get :index assert_select ev + 'time.duration[itemprop="endDate"]', false end should 'have different displays' do @block.display_as_calendar = false @block.save! get :index assert_select '.events-block', false @block.display_as_calendar = true @block.save! get :index assert_select '.events-block', true end end |