Commit 57b5f5bf85354f8908bda8d8ed5787d1399b6705
Exists in
master
and in
29 other branches
Merge branch 'master' into api
Showing
16 changed files
with
256 additions
and
124 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
@@ -8,6 +8,7 @@ class ContentViewerController < ApplicationController | @@ -8,6 +8,7 @@ class ContentViewerController < ApplicationController | ||
8 | helper TagsHelper | 8 | helper TagsHelper |
9 | 9 | ||
10 | def view_page | 10 | def view_page |
11 | + | ||
11 | path = get_path(params[:page], params[:format]) | 12 | path = get_path(params[:page], params[:format]) |
12 | 13 | ||
13 | @version = params[:version].to_i | 14 | @version = params[:version].to_i |
@@ -38,7 +39,7 @@ class ContentViewerController < ApplicationController | @@ -38,7 +39,7 @@ class ContentViewerController < ApplicationController | ||
38 | end | 39 | end |
39 | 40 | ||
40 | # At this point the page will be showed | 41 | # At this point the page will be showed |
41 | - @page.hit unless user_is_a_bot? | 42 | + @page.hit unless user_is_a_bot? || already_visited?(@page) |
42 | 43 | ||
43 | @page = FilePresenter.for @page | 44 | @page = FilePresenter.for @page |
44 | 45 | ||
@@ -272,4 +273,18 @@ class ContentViewerController < ApplicationController | @@ -272,4 +273,18 @@ class ContentViewerController < ApplicationController | ||
272 | @comment_order = params[:comment_order].nil? ? 'oldest' : params[:comment_order] | 273 | @comment_order = params[:comment_order].nil? ? 'oldest' : params[:comment_order] |
273 | end | 274 | end |
274 | 275 | ||
276 | + private | ||
277 | + | ||
278 | + def already_visited?(element) | ||
279 | + user_id = if user.nil? then -1 else current_user.id end | ||
280 | + user_id = "#{user_id}_#{element.id}_#{element.class}" | ||
281 | + | ||
282 | + if cookies.signed[:visited] == user_id | ||
283 | + return true | ||
284 | + else | ||
285 | + cookies.permanent.signed[:visited] = user_id | ||
286 | + return false | ||
287 | + end | ||
288 | + end | ||
289 | + | ||
275 | end | 290 | end |
app/controllers/public/profile_controller.rb
@@ -66,7 +66,10 @@ class ProfileController < PublicController | @@ -66,7 +66,10 @@ class ProfileController < PublicController | ||
66 | 66 | ||
67 | def members | 67 | def members |
68 | if is_cache_expired?(profile.members_cache_key(params)) | 68 | if is_cache_expired?(profile.members_cache_key(params)) |
69 | - @members = profile.members_by_name.includes(relations_to_include).paginate(:per_page => members_per_page, :page => params[:npage], :total_entries => profile.members.count) | 69 | + sort = (params[:sort] == 'desc') ? params[:sort] : 'asc' |
70 | + @profile_admins = profile.admins.includes(relations_to_include).order("name #{sort}").paginate(:per_page => members_per_page, :page => params[:npage]) | ||
71 | + @profile_members = profile.members.includes(relations_to_include).order("name #{sort}").paginate(:per_page => members_per_page, :page => params[:npage]) | ||
72 | + @profile_members_url = url_for(:controller => 'profile', :action => 'members') | ||
70 | end | 73 | end |
71 | end | 74 | end |
72 | 75 |
app/models/profile.rb
@@ -957,7 +957,8 @@ private :generate_url, :url_options | @@ -957,7 +957,8 @@ private :generate_url, :url_options | ||
957 | 957 | ||
958 | def members_cache_key(params = {}) | 958 | def members_cache_key(params = {}) |
959 | page = params[:npage] || '1' | 959 | page = params[:npage] || '1' |
960 | - cache_key + '-members-page-' + page | 960 | + sort = (params[:sort] == 'desc') ? params[:sort] : 'asc' |
961 | + cache_key + '-members-page-' + page + '-' + sort | ||
961 | end | 962 | end |
962 | 963 | ||
963 | def more_recent_label | 964 | def more_recent_label |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +<div id="profile-members-sort-options"> | ||
2 | + <%= label_tag("sort-#{role}", _("Sort by:")) %> | ||
3 | + <%= select_tag("sort-#{role}", | ||
4 | + options_for_select([ | ||
5 | + [_("Name A-Z"), 'asc'], | ||
6 | + [_("Name Z-A"), 'desc'], | ||
7 | + ], :selected => params[:sort]) | ||
8 | + ) %> | ||
9 | +</div> | ||
10 | +<ul class="profile-list-<%= role %>" > | ||
11 | + <% users.each do |u| %> | ||
12 | + <%= profile_image_link(u) %> | ||
13 | + <% end %> | ||
14 | +</ul> | ||
15 | + | ||
16 | +<%= pagination_links users, :param_name => 'npage' %> |
app/views/profile/members.html.erb
1 | <div class="common-profile-list-block"> | 1 | <div class="common-profile-list-block"> |
2 | 2 | ||
3 | -<h1><%= _("%s's members") % profile.name %></h1> | 3 | +<h1><%= _("Members (%d)") % @profile_members.total_entries %></h1> |
4 | +<h2 class="community-name"><%= profile.name %></h2> | ||
4 | 5 | ||
5 | <% cache_timeout(profile.members_cache_key(params), 4.hours) do %> | 6 | <% cache_timeout(profile.members_cache_key(params), 4.hours) do %> |
6 | - <ul class='profile-list'> | ||
7 | - <% @members.each do |member| %> | ||
8 | - <%= profile_image_link(member) %> | ||
9 | - <% end %> | ||
10 | - </ul> | 7 | + <div class="profile-members-tabs-container"> |
8 | + <% tabs = [] %> | ||
9 | + | ||
10 | + <% div_members = content_tag :div, :class => "profile-members" do | ||
11 | + render :partial => 'profile_members_list', | ||
12 | + :locals => { | ||
13 | + :users => @profile_members, | ||
14 | + :role => "members" | ||
15 | + } | ||
16 | + end %> | ||
17 | + | ||
18 | + <% tabs << {:title => _("%d Members") % @profile_members.total_entries, | ||
19 | + :id => "members-tab", | ||
20 | + :content => div_members | ||
21 | + } %> | ||
11 | 22 | ||
12 | - <div id='pagination-profiles'> | ||
13 | - <%= pagination_links @members, :param_name => 'npage' %> | ||
14 | - </div> | 23 | + <% div_admins = content_tag :div, :class => "profile-admins" do |
24 | + render :partial => 'profile_members_list', | ||
25 | + :locals => { | ||
26 | + :users => @profile_admins, | ||
27 | + :role => "admins" | ||
28 | + } | ||
29 | + end %> | ||
30 | + | ||
31 | + <% tabs << {:title => _("%d Administrators") % @profile_admins.total_entries, | ||
32 | + :id => "admins-tab", | ||
33 | + :content => div_admins | ||
34 | + } %> | ||
35 | + | ||
36 | + <%= render_tabs(tabs) %> | ||
37 | + </div><!-- end of class="profile-members-tabs-container" --> | ||
15 | <% end %> | 38 | <% end %> |
16 | 39 | ||
17 | <% button_bar do %> | 40 | <% button_bar do %> |
@@ -26,4 +49,7 @@ | @@ -26,4 +49,7 @@ | ||
26 | <% end %> | 49 | <% end %> |
27 | <% end %> | 50 | <% end %> |
28 | 51 | ||
29 | -</div><!-- fim class="common-profile-list-block" --> | 52 | +<%= hidden_field_tag "profile_url", @profile_members_url %> |
53 | +</div><!-- end of class="common-profile-list-block" --> | ||
54 | + | ||
55 | +<%= javascript_include_tag "members_page.js" %> |
lib/authenticated_system.rb
@@ -2,17 +2,21 @@ module AuthenticatedSystem | @@ -2,17 +2,21 @@ module AuthenticatedSystem | ||
2 | 2 | ||
3 | protected | 3 | protected |
4 | 4 | ||
5 | - # See impl. from http://stackoverflow.com/a/2513456/670229 | ||
6 | - def self.included? base | ||
7 | - base.around_filter do | 5 | + def self.included base |
6 | + # See impl. from http://stackoverflow.com/a/2513456/670229 | ||
7 | + base.around_filter do |&block| | ||
8 | begin | 8 | begin |
9 | User.current = current_user | 9 | User.current = current_user |
10 | - yield | 10 | + block.call |
11 | ensure | 11 | ensure |
12 | # to address the thread variable leak issues in Puma/Thin webserver | 12 | # to address the thread variable leak issues in Puma/Thin webserver |
13 | User.current = nil | 13 | User.current = nil |
14 | end | 14 | end |
15 | end | 15 | end |
16 | + | ||
17 | + # Inclusion hook to make #current_user and #logged_in? | ||
18 | + # available as ActionView helper methods. | ||
19 | + base.send :helper_method, :current_user, :logged_in? | ||
16 | end | 20 | end |
17 | 21 | ||
18 | # Returns true or false if the user is logged in. | 22 | # Returns true or false if the user is logged in. |
@@ -134,12 +138,6 @@ module AuthenticatedSystem | @@ -134,12 +138,6 @@ module AuthenticatedSystem | ||
134 | end | 138 | end |
135 | end | 139 | end |
136 | 140 | ||
137 | - # Inclusion hook to make #current_user and #logged_in? | ||
138 | - # available as ActionView helper methods. | ||
139 | - def self.included(base) | ||
140 | - base.send :helper_method, :current_user, :logged_in? | ||
141 | - end | ||
142 | - | ||
143 | # When called with before_filter :login_from_cookie will check for an :auth_token | 141 | # When called with before_filter :login_from_cookie will check for an :auth_token |
144 | # cookie and log the user back in if apropriate | 142 | # cookie and log the user back in if apropriate |
145 | def login_from_cookie | 143 | def login_from_cookie |
plugins/people_block/controllers/people_block_plugin_profile_controller.rb
@@ -1,20 +0,0 @@ | @@ -1,20 +0,0 @@ | ||
1 | -class PeopleBlockPluginProfileController < ProfileController | ||
2 | - | ||
3 | - append_view_path File.join(File.dirname(__FILE__) + '/../views') | ||
4 | - | ||
5 | - def members | ||
6 | - if is_cache_expired?(profile.members_cache_key(params)) | ||
7 | - unless params[:role_key].blank? | ||
8 | - role = Role.find_by_key_and_environment_id(params[:role_key], profile.environment) | ||
9 | - @members = profile.members.with_role(role.id) | ||
10 | - @members_title = role.name | ||
11 | - else | ||
12 | - @members = profile.members | ||
13 | - @members_title = 'members' | ||
14 | - end | ||
15 | - @members = @members.includes(relations_to_include).paginate(:per_page => members_per_page, :page => params[:npage], :total_entries => @members.count) | ||
16 | - end | ||
17 | - render "profile/members" | ||
18 | - end | ||
19 | - | ||
20 | -end |
plugins/people_block/test/functional/people_block_plugin_profile_controller_test.rb
@@ -1,76 +0,0 @@ | @@ -1,76 +0,0 @@ | ||
1 | -require_relative '../test_helper' | ||
2 | -require_relative '../../controllers/people_block_plugin_profile_controller' | ||
3 | - | ||
4 | - | ||
5 | -# Re-raise errors caught by the controller. | ||
6 | -class PeopleBlockPluginProfileController; def rescue_action(e) raise e end; end | ||
7 | - | ||
8 | -class PeopleBlockPluginProfileControllerTest < ActionController::TestCase | ||
9 | - | ||
10 | - def setup | ||
11 | - @controller = PeopleBlockPluginProfileController.new | ||
12 | - @request = ActionController::TestRequest.new | ||
13 | - @response = ActionController::TestResponse.new | ||
14 | - | ||
15 | - @profile = fast_create(Community) | ||
16 | - | ||
17 | - @environment = @profile.environment | ||
18 | - @environment.enabled_plugins = ['PeopleBlockPlugin'] | ||
19 | - @environment.save! | ||
20 | - | ||
21 | - MembersBlock.delete_all | ||
22 | - @block = MembersBlock.new | ||
23 | - @block.box = @profile.boxes.first | ||
24 | - @block.save! | ||
25 | - | ||
26 | - @admin = create_user('adminprofile').person | ||
27 | - @member = create_user('memberprofile').person | ||
28 | - @moderator = create_user('moderatorprofile').person | ||
29 | - @profile.add_moderator(@moderator) | ||
30 | - @profile.add_member(@member) | ||
31 | - @profile.add_admin(@admin) | ||
32 | - end | ||
33 | - | ||
34 | - attr_accessor :profile, :block, :admin, :member, :moderator | ||
35 | - | ||
36 | - should 'list members without role_key' do | ||
37 | - get :members, :profile => profile.identifier, :role_key => "" | ||
38 | - assert_response :success | ||
39 | - assert_template 'members' | ||
40 | - assert_equivalent [@admin, @member, @moderator], assigns(:members) | ||
41 | - assert_match /adminprofile/, @response.body | ||
42 | - assert_match /memberprofile/, @response.body | ||
43 | - assert_match /moderatorprofile/, @response.body | ||
44 | - end | ||
45 | - | ||
46 | - should 'list members with role_key=nil' do | ||
47 | - get :members, :profile => profile.identifier, :role_key => nil | ||
48 | - assert_response :success | ||
49 | - assert_template 'members' | ||
50 | - assert_equivalent [@admin, @member, @moderator], assigns(:members) | ||
51 | - assert_match /adminprofile/, @response.body | ||
52 | - assert_match /memberprofile/, @response.body | ||
53 | - assert_match /moderatorprofile/, @response.body | ||
54 | - end | ||
55 | - | ||
56 | - should 'list members only' do | ||
57 | - get :members, :profile => profile.identifier, :role_key => Profile::Roles.member(profile.environment.id).key | ||
58 | - assert_response :success | ||
59 | - assert_template 'members' | ||
60 | - assert_equal [@member], assigns(:members) | ||
61 | - assert_no_match /adminprofile/, @response.body | ||
62 | - assert_match /memberprofile/, @response.body | ||
63 | - assert_no_match /moderatorprofile/, @response.body | ||
64 | - end | ||
65 | - | ||
66 | - should 'list moderators only' do | ||
67 | - get :members, :profile => profile.identifier, :role_key => Profile::Roles.moderator(profile.environment.id).key | ||
68 | - assert_response :success | ||
69 | - assert_template 'members' | ||
70 | - assert_equal [@moderator], assigns(:members) | ||
71 | - assert_no_match /adminprofile/, @response.body | ||
72 | - assert_no_match /memberprofile/, @response.body | ||
73 | - assert_match /moderatorprofile/, @response.body | ||
74 | - end | ||
75 | - | ||
76 | -end |
plugins/people_block/test/unit/members_block_test.rb
@@ -147,11 +147,11 @@ class MembersBlockTest < ActionView::TestCase | @@ -147,11 +147,11 @@ class MembersBlockTest < ActionView::TestCase | ||
147 | 147 | ||
148 | instance_eval(&block.footer) | 148 | instance_eval(&block.footer) |
149 | assert_select 'a.view-all' do |elements| | 149 | assert_select 'a.view-all' do |elements| |
150 | - assert_select '[href=/profile/mytestuser/plugin/people_block/members]' | 150 | + assert_select "[href=/profile/mytestuser/members#members-tab]" |
151 | end | 151 | end |
152 | end | 152 | end |
153 | 153 | ||
154 | - should 'provide link to members page with a selected role' do | 154 | + should 'provide link to members page when visible_role is profile_member' do |
155 | profile = create_user('mytestuser').person | 155 | profile = create_user('mytestuser').person |
156 | block = MembersBlock.new | 156 | block = MembersBlock.new |
157 | block.box = profile.boxes.first | 157 | block.box = profile.boxes.first |
@@ -160,7 +160,33 @@ class MembersBlockTest < ActionView::TestCase | @@ -160,7 +160,33 @@ class MembersBlockTest < ActionView::TestCase | ||
160 | 160 | ||
161 | instance_eval(&block.footer) | 161 | instance_eval(&block.footer) |
162 | assert_select 'a.view-all' do |elements| | 162 | assert_select 'a.view-all' do |elements| |
163 | - assert_select '[href=/profile/mytestuser/plugin/people_block/members?role_key=profile_member]' | 163 | + assert_select '[href=/profile/mytestuser/members#members-tab]' |
164 | + end | ||
165 | + end | ||
166 | + | ||
167 | + should 'provide link to members page when visible_role is profile_moderator' do | ||
168 | + profile = create_user('mytestuser').person | ||
169 | + block = MembersBlock.new | ||
170 | + block.box = profile.boxes.first | ||
171 | + block.visible_role = 'profile_moderator' | ||
172 | + block.save! | ||
173 | + | ||
174 | + instance_eval(&block.footer) | ||
175 | + assert_select 'a.view-all' do |elements| | ||
176 | + assert_select '[href=/profile/mytestuser/members#members-tab]' | ||
177 | + end | ||
178 | + end | ||
179 | + | ||
180 | + should 'provide link to admins page when visible_role is profile_admin' do | ||
181 | + profile = create_user('mytestuser').person | ||
182 | + block = MembersBlock.new | ||
183 | + block.box = profile.boxes.first | ||
184 | + block.visible_role = 'profile_admin' | ||
185 | + block.save! | ||
186 | + | ||
187 | + instance_eval(&block.footer) | ||
188 | + assert_select 'a.view-all' do |elements| | ||
189 | + assert_select '[href=/profile/mytestuser/members#admins-tab]' | ||
164 | end | 190 | end |
165 | end | 191 | end |
166 | 192 |
plugins/people_block/views/blocks/members.html.erb
1 | -<%= link_to c_('View all'), {:profile => profile.identifier, :controller => 'people_block_plugin_profile', :action => 'members', :role_key => role_key}, :class => 'view-all' %> | 1 | +<% anchor = role_key == "profile_admin" ? "admins-tab" : "members-tab" %> |
2 | +<%= link_to c_('View all'), {:profile => profile.identifier, :controller => 'profile', :action => 'members', :anchor =>anchor }, :class => 'view-all' %> | ||
2 | 3 | ||
3 | <% if show_join_leave_button %> | 4 | <% if show_join_leave_button %> |
4 | <%= render :partial => 'blocks/profile_info_actions/join_leave_community' %> | 5 | <%= render :partial => 'blocks/profile_info_actions/join_leave_community' %> |
public/designs/themes/base/style.scss
@@ -231,6 +231,10 @@ body, th, td, input { | @@ -231,6 +231,10 @@ body, th, td, input { | ||
231 | border-left: 0px; | 231 | border-left: 0px; |
232 | } | 232 | } |
233 | 233 | ||
234 | +.menu-submenu-list>li{ | ||
235 | + width: 100%; | ||
236 | +} | ||
237 | + | ||
234 | #navigation .menu-submenu ul{ | 238 | #navigation .menu-submenu ul{ |
235 | border: 1px solid #888a85; | 239 | border: 1px solid #888a85; |
236 | border-top: 0px; | 240 | border-top: 0px; |
@@ -1534,3 +1538,7 @@ table#recaptcha_table tr:hover td { | @@ -1534,3 +1538,7 @@ table#recaptcha_table tr:hover td { | ||
1534 | width: 494px; | 1538 | width: 494px; |
1535 | padding-left: 2px; | 1539 | padding-left: 2px; |
1536 | } | 1540 | } |
1541 | + | ||
1542 | +.profile-members-title-sort { | ||
1543 | + clear: both; | ||
1544 | +} |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +(function($) { | ||
2 | + "use strict"; | ||
3 | + | ||
4 | + function set_members_sort() { | ||
5 | + var profile_members_url = $("#profile_url").val(); | ||
6 | + | ||
7 | + $("#sort-members, #sort-admins").on("change", function() { | ||
8 | + var sort_value = this.value; | ||
9 | + var role = this.id; | ||
10 | + role = role.replace("sort-", ''); | ||
11 | + var actual_page_content = $(".profile-list-"+role); | ||
12 | + | ||
13 | + $.get(profile_members_url, {sort: sort_value}, function(response) { | ||
14 | + var html_response = $(response); | ||
15 | + | ||
16 | + actual_page_content.html(html_response.find(".profile-list-"+role).html()); | ||
17 | + }); | ||
18 | + }); | ||
19 | + } | ||
20 | + | ||
21 | + $(document).ready(function() { | ||
22 | + set_members_sort(); | ||
23 | + }); | ||
24 | +}) (jQuery); |
public/stylesheets/application.scss
@@ -4777,6 +4777,11 @@ h1#agenda-title { | @@ -4777,6 +4777,11 @@ h1#agenda-title { | ||
4777 | background-image: url(../images/control-panel/role-management.gif) | 4777 | background-image: url(../images/control-panel/role-management.gif) |
4778 | } | 4778 | } |
4779 | /* ==> public/stylesheets/controller_profile_members.css <== */ | 4779 | /* ==> public/stylesheets/controller_profile_members.css <== */ |
4780 | + | ||
4781 | +.profile-members-tabs-container .ui-corner-all { | ||
4782 | + overflow: auto; | ||
4783 | +} | ||
4784 | + | ||
4780 | .controller-profile_members .no-boxes { | 4785 | .controller-profile_members .no-boxes { |
4781 | margin: 30px | 4786 | margin: 30px |
4782 | } | 4787 | } |
@@ -5432,6 +5437,7 @@ h1#agenda-title { | @@ -5432,6 +5437,7 @@ h1#agenda-title { | ||
5432 | margin: 0; | 5437 | margin: 0; |
5433 | padding: 0; | 5438 | padding: 0; |
5434 | width: 100%; | 5439 | width: 100%; |
5440 | + height: 92px; | ||
5435 | } | 5441 | } |
5436 | #content .menu-submenu-content ul { | 5442 | #content .menu-submenu-content ul { |
5437 | margin: 0; | 5443 | margin: 0; |
test/functional/application_controller_test.rb
@@ -191,6 +191,16 @@ class ApplicationControllerTest < ActionController::TestCase | @@ -191,6 +191,16 @@ class ApplicationControllerTest < ActionController::TestCase | ||
191 | assert_tag :tag => 'option', :attributes => { :value => 'it' }, :content => 'Italiano' | 191 | assert_tag :tag => 'option', :attributes => { :value => 'it' }, :content => 'Italiano' |
192 | end | 192 | end |
193 | 193 | ||
194 | + should 'set and unset the current user' do | ||
195 | + testuser = create_user 'testuser' | ||
196 | + login_as 'testuser' | ||
197 | + User.expects(:current=).with do |user| | ||
198 | + user == testuser | ||
199 | + end.at_least_once | ||
200 | + User.expects(:current=).with(nil).at_least_once | ||
201 | + get :index | ||
202 | + end | ||
203 | + | ||
194 | should 'display link to webmail if enabled for system' do | 204 | should 'display link to webmail if enabled for system' do |
195 | @controller.stubs(:get_layout).returns('application') | 205 | @controller.stubs(:get_layout).returns('application') |
196 | login_as('ze') | 206 | login_as('ze') |
test/functional/content_viewer_controller_test.rb
@@ -1587,4 +1587,33 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -1587,4 +1587,33 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
1587 | assert_tag :tag => 'div', :attributes => { :class => 'article-compact-image' } | 1587 | assert_tag :tag => 'div', :attributes => { :class => 'article-compact-image' } |
1588 | assert_tag :tag => 'div', :attributes => { :class => 'article-compact-abstract-with-image' } | 1588 | assert_tag :tag => 'div', :attributes => { :class => 'article-compact-abstract-with-image' } |
1589 | end | 1589 | end |
1590 | + | ||
1591 | + should 'not count a visit twice for the same user' do | ||
1592 | + profile = create_user('someone').person | ||
1593 | + login_as(@profile.identifier) | ||
1594 | + page = profile.articles.build(:name => 'myarticle', :body => 'the body of the text') | ||
1595 | + page.save! | ||
1596 | + | ||
1597 | + get :view_page, :profile => profile.identifier, :page => 'myarticle' | ||
1598 | + page.reload | ||
1599 | + assert_equal 1, page.hits | ||
1600 | + | ||
1601 | + get :view_page, :profile => profile.identifier, :page => 'myarticle' | ||
1602 | + page.reload | ||
1603 | + assert_equal 1, page.hits | ||
1604 | + end | ||
1605 | + | ||
1606 | + should 'not count a visit twice for unlogged users' do | ||
1607 | + profile = create_user('someone').person | ||
1608 | + page = profile.articles.build(:name => 'myarticle', :body => 'the body of the text') | ||
1609 | + page.save! | ||
1610 | + | ||
1611 | + get :view_page, :profile => profile.identifier, :page => 'myarticle' | ||
1612 | + page.reload | ||
1613 | + assert_equal 1, page.hits | ||
1614 | + | ||
1615 | + get :view_page, :profile => profile.identifier, :page => 'myarticle' | ||
1616 | + page.reload | ||
1617 | + assert_equal 1, page.hits | ||
1618 | + end | ||
1590 | end | 1619 | end |
test/functional/profile_controller_test.rb
@@ -55,7 +55,8 @@ class ProfileControllerTest < ActionController::TestCase | @@ -55,7 +55,8 @@ class ProfileControllerTest < ActionController::TestCase | ||
55 | 55 | ||
56 | assert_response :success | 56 | assert_response :success |
57 | assert_template 'members' | 57 | assert_template 'members' |
58 | - assert assigns(:members) | 58 | + assert assigns(:profile_members) |
59 | + assert assigns(:profile_admins) | ||
59 | end | 60 | end |
60 | 61 | ||
61 | should 'list favorite enterprises' do | 62 | should 'list favorite enterprises' do |
@@ -1747,4 +1748,68 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1747,4 +1748,68 @@ class ProfileControllerTest < ActionController::TestCase | ||
1747 | assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :content => /#{person.enterprises.count}/, :attributes => { :href => /profile\/#{person.identifier}\/enterprises$/ }} | 1748 | assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :content => /#{person.enterprises.count}/, :attributes => { :href => /profile\/#{person.identifier}\/enterprises$/ }} |
1748 | end | 1749 | end |
1749 | 1750 | ||
1751 | + should 'admins from a community be present in admin users div and members div' do | ||
1752 | + community = fast_create(Community) | ||
1753 | + another_user = create_user('another_user').person | ||
1754 | + | ||
1755 | + login_as(@profile.identifier) | ||
1756 | + | ||
1757 | + community.add_admin(@profile) | ||
1758 | + | ||
1759 | + assert community.admins.include? @profile | ||
1760 | + get :members, :profile => community.identifier | ||
1761 | + | ||
1762 | + assert_tag :tag => 'ul', :attributes => { :class => /profile-list-admins/}, | ||
1763 | + :descendant => { :tag => 'a', :attributes => { :title => "testuser" } } | ||
1764 | + | ||
1765 | + assert_tag :tag => 'ul', :attributes => { :class => /profile-list-members/}, | ||
1766 | + :descendant => { :tag => 'a', :attributes => { :title => "testuser" } } | ||
1767 | + end | ||
1768 | + | ||
1769 | + should 'all members, except admins, be present in members div' do | ||
1770 | + community = fast_create(Community) | ||
1771 | + community.add_member(@profile) | ||
1772 | + | ||
1773 | + another_user = create_user('another_user').person | ||
1774 | + community.add_member(another_user) | ||
1775 | + | ||
1776 | + assert_equal false, community.admins.include?(another_user) | ||
1777 | + | ||
1778 | + get :members, :profile => community.identifier | ||
1779 | + | ||
1780 | + assert_tag :tag => 'ul', :attributes => { :class => /profile-list-members/}, | ||
1781 | + :descendant => { :tag => 'a', :attributes => { :title => "another_user" } } | ||
1782 | + | ||
1783 | + assert_no_tag :tag => 'ul', :attributes => { :class => /profile-list-admins/}, | ||
1784 | + :descendant => { :tag => 'a', :attributes => { :title => "another_user" } } | ||
1785 | + end | ||
1786 | + | ||
1787 | + should 'members be sorted by name in ascendant order' do | ||
1788 | + community = fast_create(Community) | ||
1789 | + another_user = create_user('another_user').person | ||
1790 | + different_user = create_user('different_user').person | ||
1791 | + | ||
1792 | + community.add_member(@profile) | ||
1793 | + community.add_member(another_user) | ||
1794 | + community.add_member(different_user) | ||
1795 | + | ||
1796 | + get :members, :profile => community.identifier, :sort => "asc" | ||
1797 | + | ||
1798 | + assert @response.body.index("another_user") < @response.body.index("different_user") | ||
1799 | + end | ||
1800 | + | ||
1801 | + should 'members be sorted by name in descendant order' do | ||
1802 | + community = fast_create(Community) | ||
1803 | + another_user = create_user('another_user').person | ||
1804 | + different_user = create_user('different_user').person | ||
1805 | + | ||
1806 | + community.add_member(@profile) | ||
1807 | + community.add_member(another_user) | ||
1808 | + community.add_member(different_user) | ||
1809 | + | ||
1810 | + get :members, :profile => community.identifier, :sort => "desc" | ||
1811 | + | ||
1812 | + assert @response.body.index("another_user") > @response.body.index("different_user") | ||
1813 | + end | ||
1814 | + | ||
1750 | end | 1815 | end |