community_hub_plugin_content_viewer_controller_test.rb
3.36 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
require File.dirname(__FILE__) + '/../test_helper'
require 'content_viewer_controller'
class ContentViewerController; def rescue_action(e) raise e end; end
class ContentViewerControllerTest < ActionController::TestCase
all_fixtures
def setup
@controller = ContentViewerController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@user = create_user('testinguser').person
@environment = @user.environment
@community = Community.create!(
:name => 'Sample community',
:identifier => 'sample-community',
:environment => @environment
)
@hub = CommunityHubPlugin::Hub.new(
:abstract => 'abstract',
:body => 'body',
:name => 'test-hub',
:profile => community,
:last_changed_by_id => user.id
)
@hub.save!
end
attr_reader :user, :environment, :community, :hub
should 'display live tab' do
get :view_page, @hub.url
assert_tag :tag => 'div', :attributes => { :id => 'left-tab' }
end
should 'display mediation tab' do
get :view_page, @hub.url
assert_tag :tag => 'div', :attributes => { :id => 'right-tab' }
end
should 'display auto scroll checkbox for live stream content' do
get :view_page, @hub.url
assert_tag :tag => 'div', :attributes => { :id => 'left-tab' }, :descendant => {
:tag => 'span', :descendant => {
:tag => 'input', :attributes => { :id => 'auto_scrolling', :type => 'checkbox' }
}
}
end
should 'not display auto scroll setting for mediation content' do
get :view_page, @hub.url
assert_no_tag :tag => 'div', :attributes => { :id => 'right-tab' }, :descendant => {
:tag => 'span', :descendant => {
:tag => 'input', :attributes => { :id => 'auto_scrolling', :type => 'checkbox' }
}
}
end
should 'not display message form if user is not logged' do
get :view_page, @hub.url
assert_no_tag :tag => 'div', :attributes => { :class => 'form-message' }
end
should 'not display mediation form if user is not loged' do
get :view_page, @hub.url
assert_no_tag :tag => 'div', :attributes => { :class => 'form-mediation' }
end
should 'display message form if user is logged' do
user = create_user('visitor')
login_as(user.login)
get :view_page, @hub.url
assert_tag :tag => 'div', :attributes => { :class => 'form-message' }
end
should 'display mediation form if user is logged and is hub''s mediator' do
login_as(user.user.login)
get :view_page, @hub.url
assert_tag :tag => 'div', :attributes => { :class => 'form-mediation' }
end
should 'not display mediation form if user is logged but is not hub''s mediator' do
visitor = create_user('visitor')
login_as(visitor.login)
assert_no_tag :tag => 'div', :attributes => { :class => 'form-mediation' }
end
should 'display link to hub''s settings if user is mediator' do
login_as(user.user.login)
get :view_page, @hub.url
assert_tag :tag => 'div', :attributes => { :class => 'settings' }
end
should 'not display link to hub''s settings if user is not mediator' do
visitor = create_user('visitor')
login_as(visitor.login)
get :view_page, @hub.url
assert_no_tag :tag => 'div', :attributes => { :class => 'settings' }
end
end