activities_controller_test.rb
166 lines
| 5.7 KiB
| text/x-ruby
|
RubyLexer
|
r4395 | require File.expand_path('../../test_helper', __FILE__) | ||
|
r3933 | |||
class ActivitiesControllerTest < ActionController::TestCase | ||||
|
r7366 | fixtures :projects, :trackers, :issue_statuses, :issues, | ||
:enumerations, :users, :issue_categories, | ||||
:projects_trackers, | ||||
:roles, | ||||
:member_roles, | ||||
:members, | ||||
:groups_users, | ||||
:enabled_modules, | ||||
:workflows, | ||||
:journals, :journal_details | ||||
|
r3933 | |||
def test_project_index | ||||
get :index, :id => 1, :with_subprojects => 0 | ||||
assert_response :success | ||||
assert_template 'index' | ||||
assert_not_nil assigns(:events_by_day) | ||||
|
r5676 | |||
assert_tag :tag => "h3", | ||||
|
r3933 | :content => /#{2.days.ago.to_date.day}/, | ||
:sibling => { :tag => "dl", | ||||
:child => { :tag => "dt", | ||||
:attributes => { :class => /issue-edit/ }, | ||||
:child => { :tag => "a", | ||||
:content => /(#{IssueStatus.find(2).name})/, | ||||
} | ||||
} | ||||
} | ||||
end | ||||
|
r5676 | |||
|
r7866 | def test_project_index_with_invalid_project_id_should_respond_404 | ||
get :index, :id => 299 | ||||
assert_response 404 | ||||
end | ||||
|
r3933 | def test_previous_project_index | ||
get :index, :id => 1, :from => 3.days.ago.to_date | ||||
assert_response :success | ||||
assert_template 'index' | ||||
assert_not_nil assigns(:events_by_day) | ||||
|
r5676 | |||
assert_tag :tag => "h3", | ||||
|
r3933 | :content => /#{3.day.ago.to_date.day}/, | ||
:sibling => { :tag => "dl", | ||||
:child => { :tag => "dt", | ||||
:attributes => { :class => /issue/ }, | ||||
:child => { :tag => "a", | ||||
|
r10092 | :content => /Can't print recipes/, | ||
|
r3933 | } | ||
} | ||||
} | ||||
end | ||||
|
r5676 | |||
|
r3933 | def test_global_index | ||
|
r9688 | @request.session[:user_id] = 1 | ||
|
r3933 | get :index | ||
assert_response :success | ||||
assert_template 'index' | ||||
assert_not_nil assigns(:events_by_day) | ||||
|
r5676 | |||
|
r9688 | i5 = Issue.find(5) | ||
d5 = User.find(1).time_to_date(i5.created_on) | ||||
|
r5676 | assert_tag :tag => "h3", | ||
|
r9688 | :content => /#{d5.day}/, | ||
|
r3933 | :sibling => { :tag => "dl", | ||
:child => { :tag => "dt", | ||||
:attributes => { :class => /issue/ }, | ||||
:child => { :tag => "a", | ||||
|
r10092 | :content => /Subproject issue/, | ||
|
r3933 | } | ||
} | ||||
} | ||||
end | ||||
|
r5676 | |||
|
r3933 | def test_user_index | ||
|
r9631 | @request.session[:user_id] = 1 | ||
|
r3933 | get :index, :user_id => 2 | ||
assert_response :success | ||||
assert_template 'index' | ||||
assert_not_nil assigns(:events_by_day) | ||||
|
r5676 | |||
|
r9603 | assert_select 'h2 a[href=/users/2]', :text => 'John Smith' | ||
|
r9631 | i1 = Issue.find(1) | ||
d1 = User.find(1).time_to_date(i1.created_on) | ||||
|
r5676 | assert_tag :tag => "h3", | ||
|
r9631 | :content => /#{d1.day}/, | ||
|
r3933 | :sibling => { :tag => "dl", | ||
:child => { :tag => "dt", | ||||
:attributes => { :class => /issue/ }, | ||||
:child => { :tag => "a", | ||||
|
r10092 | :content => /Can't print recipes/, | ||
|
r3933 | } | ||
} | ||||
} | ||||
end | ||||
|
r5676 | |||
|
r7866 | def test_user_index_with_invalid_user_id_should_respond_404 | ||
get :index, :user_id => 299 | ||||
assert_response 404 | ||||
end | ||||
|
r3933 | def test_index_atom_feed | ||
|
r8526 | get :index, :format => 'atom', :with_subprojects => 0 | ||
|
r3933 | assert_response :success | ||
|
r8962 | assert_template 'common/feed' | ||
|
r8526 | |||
assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | ||||
:attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'} | ||||
assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | ||||
:attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'} | ||||
assert_tag :tag => 'entry', :child => { | ||||
:tag => 'link', | ||||
:attributes => {:href => 'http://test.host/issues/11'}} | ||||
end | ||||
def test_index_atom_feed_with_explicit_selection | ||||
get :index, :format => 'atom', :with_subprojects => 0, | ||||
:show_changesets => 1, | ||||
:show_documents => 1, | ||||
:show_files => 1, | ||||
:show_issues => 1, | ||||
:show_messages => 1, | ||||
:show_news => 1, | ||||
:show_time_entries => 1, | ||||
:show_wiki_edits => 1 | ||||
assert_response :success | ||||
|
r8962 | assert_template 'common/feed' | ||
|
r8526 | |||
assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | ||||
:attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} | ||||
assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | ||||
:attributes => {:rel => 'alternate', :href => 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} | ||||
|
r3933 | assert_tag :tag => 'entry', :child => { | ||
:tag => 'link', | ||||
:attributes => {:href => 'http://test.host/issues/11'}} | ||||
end | ||||
|
r7866 | |||
def test_index_atom_feed_with_one_item_type | ||||
get :index, :format => 'atom', :show_issues => '1' | ||||
assert_response :success | ||||
|
r8962 | assert_template 'common/feed' | ||
|
r7866 | assert_tag :tag => 'title', :content => /Issues/ | ||
end | ||||
|
r10336 | |||
def test_index_should_show_private_notes_with_permission_only | ||||
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true) | ||||
@request.session[:user_id] = 2 | ||||
get :index | ||||
assert_response :success | ||||
assert_include journal, assigns(:events_by_day).values.flatten | ||||
Role.find(1).remove_permission! :view_private_notes | ||||
get :index | ||||
assert_response :success | ||||
assert_not_include journal, assigns(:events_by_day).values.flatten | ||||
end | ||||
|
r3933 | end | ||