events_block_test.rb
1.19 KB
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
require_relative '../test_helper'
class EventsBlockTest < ActiveSupport::TestCase
should 'describe itself' do
assert_not_equal Block.description, EventsPlugin::EventsBlock.description
end
should 'is editable' do
block = EventsPlugin::EventsBlock.new
assert block.editable?
end
should 'return events' do
profile = create(Profile, name: 'Test')
event1 = create(Event, profile: profile)
event2 = create(Event, profile: profile)
event3 = create(Event, profile: create(Profile, name: 'Other'))
block = EventsPlugin::EventsBlock.new
block.stubs(:owner).returns(profile)
assert_equal [event1, event2].map(&:id), block.events.map(&:id)
end
end
require 'boxes_helper'
class EventsBlockViewTest < ActionView::TestCase
include BoxesHelper
should 'return events in api_content' do
profile = create(Profile, name: 'Test')
event1 = create(Event, profile: profile)
event2 = create(Event, profile: profile)
event3 = create(Event, profile: create(Profile, name: 'Other'))
block = EventsPlugin::EventsBlock.new
block.stubs(:owner).returns(profile)
assert_equal [event1.id, event2.id], block.api_content[:events].map{ |e| e[:id] }
end
end