Skip to content

Commit

Permalink
Use #assert_select instead of #assert_tag.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11066 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Dec 22, 2012
1 parent eecabc5 commit 3976d5e
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 208 deletions.
2 changes: 1 addition & 1 deletion app/views/context_menus/issues.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<% end %>

<% @options_by_custom_field.each do |field, options| %>
<li class="folder">
<li class="folder cf_<%= field.id %>">
<a href="#" class="submenu"><%= h(field.name) %></a>
<ul>
<% options.each do |text, value| %>
Expand Down
4 changes: 2 additions & 2 deletions test/functional/account_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def test_get_register_with_registration_on
assert_template 'register'
assert_not_nil assigns(:user)

assert_tag 'input', :attributes => {:name => 'user[password]'}
assert_tag 'input', :attributes => {:name => 'user[password_confirmation]'}
assert_select 'input[name=?]', 'user[password]'
assert_select 'input[name=?]', 'user[password_confirmation]'
end
end

Expand Down
82 changes: 25 additions & 57 deletions test/functional/activities_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,8 @@ def test_project_index
assert_template 'index'
assert_not_nil assigns(:events_by_day)

assert_tag :tag => "h3",
: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})/,
}
}
}
assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
end

def test_project_index_with_invalid_project_id_should_respond_404
Expand All @@ -59,16 +51,8 @@ def test_previous_project_index
assert_template 'index'
assert_not_nil assigns(:events_by_day)

assert_tag :tag => "h3",
:content => /#{3.day.ago.to_date.day}/,
:sibling => { :tag => "dl",
:child => { :tag => "dt",
:attributes => { :class => /issue/ },
:child => { :tag => "a",
:content => /Can&#x27;t print recipes/,
}
}
}
assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
end

def test_global_index
Expand All @@ -80,16 +64,9 @@ def test_global_index

i5 = Issue.find(5)
d5 = User.find(1).time_to_date(i5.created_on)
assert_tag :tag => "h3",
:content => /#{d5.day}/,
:sibling => { :tag => "dl",
:child => { :tag => "dt",
:attributes => { :class => /issue/ },
:child => { :tag => "a",
:content => /Subproject issue/,
}
}
}

assert_select 'h3', :text => /#{d5.day}/
assert_select 'dl dt.issue a', :text => /Subproject issue/
end

def test_user_index
Expand All @@ -104,16 +81,8 @@ def test_user_index
i1 = Issue.find(1)
d1 = User.find(1).time_to_date(i1.created_on)

assert_tag :tag => "h3",
:content => /#{d1.day}/,
:sibling => { :tag => "dl",
:child => { :tag => "dt",
:attributes => { :class => /issue/ },
:child => { :tag => "a",
:content => /Can&#x27;t print recipes/,
}
}
}
assert_select 'h3', :text => /#{d1.day}/
assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
end

def test_user_index_with_invalid_user_id_should_respond_404
Expand All @@ -126,14 +95,13 @@ def test_index_atom_feed
assert_response :success
assert_template 'common/feed'

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'}}
assert_select 'feed' do
assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
assert_select 'entry' do
assert_select 'link[href=?]', 'http://test.host/issues/11'
end
end
end

def test_index_atom_feed_with_explicit_selection
Expand All @@ -150,21 +118,21 @@ def test_index_atom_feed_with_explicit_selection
assert_response :success
assert_template 'common/feed'

assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
:attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'}
assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
:attributes => {:rel => 'alternate', :href => 'http://test.host/activity?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'}

assert_tag :tag => 'entry', :child => {
:tag => 'link',
:attributes => {:href => 'http://test.host/issues/11'}}
assert_select 'feed' do
assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
assert_select 'entry' do
assert_select 'link[href=?]', 'http://test.host/issues/11'
end
end
end

def test_index_atom_feed_with_one_item_type
get :index, :format => 'atom', :show_issues => '1'
assert_response :success
assert_template 'common/feed'
assert_tag :tag => 'title', :content => /Issues/

assert_select 'title', :text => /Issues/
end

def test_index_should_show_private_notes_with_permission_only
Expand Down
5 changes: 3 additions & 2 deletions test/functional/boards_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ def test_show_with_permission_should_display_the_new_message_form
assert_response :success
assert_template 'show'

assert_tag 'form', :attributes => {:id => 'message-form'}
assert_tag 'input', :attributes => {:name => 'message[subject]'}
assert_select 'form#message-form' do
assert_select 'input[name=?]', 'message[subject]'
end
end

def test_show_atom
Expand Down
50 changes: 20 additions & 30 deletions test/functional/calendars_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,42 +56,32 @@ def test_week_number_calculation
get :show, :month => '1', :year => '2010'
assert_response :success

assert_tag :tag => 'tr',
:descendant => {:tag => 'td',
:attributes => {:class => 'week-number'}, :content => '53'},
:descendant => {:tag => 'td',
:attributes => {:class => 'odd'}, :content => '27'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '2'}

assert_tag :tag => 'tr',
:descendant => {:tag => 'td',
:attributes => {:class => 'week-number'}, :content => '1'},
:descendant => {:tag => 'td',
:attributes => {:class => 'odd'}, :content => '3'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '9'}
assert_select 'tr' do
assert_select 'td.week-number', :text => '53'
assert_select 'td.odd', :text => '27'
assert_select 'td.even', :text => '2'
end

assert_select 'tr' do
assert_select 'td.week-number', :text => '1'
assert_select 'td.odd', :text => '3'
assert_select 'td.even', :text => '9'
end

Setting.start_of_week = 1
get :show, :month => '1', :year => '2010'
assert_response :success

assert_tag :tag => 'tr',
:descendant => {:tag => 'td',
:attributes => {:class => 'week-number'}, :content => '53'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '28'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '3'}

assert_tag :tag => 'tr',
:descendant => {:tag => 'td',
:attributes => {:class => 'week-number'}, :content => '1'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '4'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '10'}
assert_select 'tr' do
assert_select 'td.week-number', :text => '53'
assert_select 'td.even', :text => '28'
assert_select 'td.even', :text => '3'
end

assert_select 'tr' do
assert_select 'td.week-number', :text => '1'
assert_select 'td.even', :text => '4'
assert_select 'td.even', :text => '10'
end
end
end
Loading

0 comments on commit 3976d5e

Please sign in to comment.