video_plugin_myprofile_controller_test.rb
3.82 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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
require File.dirname(__FILE__) + '/../test_helper'
# Re-raise errors caught by the controller.
class ProfileDesignController; def rescue_action(e) raise e end; end
class ProfileDesignControllerTest < ActionController::TestCase
def setup
@controller = ProfileDesignController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
user = create_user('testinguser')
login_as(user.login)
@profile = user.person
@environment = @profile.environment
@environment.enabled_plugins = ['VideoPlugin']
@environment.save!
VideoBlock.delete_all
@box1 = Box.create!(:owner => @profile)
@profile.boxes = [@box1]
@block = VideoBlock.new
@block.box = @box1
@block.save!
@profile.blocks<<@block
@profile.save!
end
attr_accessor :profile, :block
should 'display video-block-data class in profile block edition' do
block.url='youtube.com/?v=XXXXX'
block.save
get :index, :profile => profile.identifier
assert_tag :div, :attributes => {:class => 'video-block-data'}
end
should "display iframe tag in profile block edition on youtube url's" do
block.url='youtube.com/?v=XXXXX'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'iframe'
end
should "the width in iframe tag be defined on youtube url's" do
block.url='youtube.com/?v=XXXXX'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'iframe', :attributes => {:width => '400px'}
end
should "display iframe tag in profile block edition on vimeo url's" do
block.url='http://vimeo.com/98979'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'iframe'
end
should "the width in iframe tag be defined on vimeo url's" do
block.url='http://vimeo.com/98979'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'iframe', :attributes => {:width => '400px'}
end
should "display video tag in profile block edition for any video url" do
block.url='http://www.vmsd.com/98979.mp4'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'video'
end
should "the width in video tag be defined for any video url" do
block.url='http://www.vmsd.com/98979.mp4'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'video', :attributes => {:width => '400px'}
end
should 'the heigth in iframe tag be defined' do
block.url='youtube.com/?v=XXXXX'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'iframe', :attributes => {:height => '315px'}
end
should 'display youtube videos' do
block.url='youtube.com/?v=XXXXX'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'youtube'} }
end
should 'display vimeo videos' do
block.url='http://vimeo.com/98979'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'vimeo'} }
end
should 'display other videos' do
block.url='http://www.vmsd.com/98979.mp4'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'video'} }
end
should 'display a messagem to register a new url' do
block.url='http://www.vmsd.com/test.pdf'
block.save
get :index, :profile => profile.identifier
assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'span', :attributes => {:class => 'alert-block'} }
end
end