Commit 4eab743095448859c828a0466d4466b38797a969
1 parent
1ad440bd
Exists in
master
and in
1 other branch
fixed button 'show/hide resolved' on errors#index page
Showing
3 changed files
with
23 additions
and
4 deletions
Show diff stats
app/views/apps/show.html.haml
| @@ -91,7 +91,7 @@ | @@ -91,7 +91,7 @@ | ||
| 91 | - if app.problems.any? | 91 | - if app.problems.any? |
| 92 | %h3.clear=t('.errors') | 92 | %h3.clear=t('.errors') |
| 93 | %section | 93 | %section |
| 94 | - = render 'problems/search', :all_errs => @all_errs, :app_id => app.id | 94 | + = render 'problems/search', :all_errs => all_errs, :app_id => app.id |
| 95 | %br | 95 | %br |
| 96 | %section | 96 | %section |
| 97 | .problem_table{:id => 'problem_table'} | 97 | .problem_table{:id => 'problem_table'} |
app/views/problems/index.html.haml
| 1 | -- content_for :title, @all_errs ? 'All Errors' : 'Unresolved Errors' | 1 | +- content_for :title, all_errs ? 'All Errors' : 'Unresolved Errors' |
| 2 | - content_for :head do | 2 | - content_for :head do |
| 3 | = auto_discovery_link_tag :atom, problems_path(User.token_authentication_key => current_user.authentication_token, :format => "atom"), :title => "Errbit notices at #{request.host}" | 3 | = auto_discovery_link_tag :atom, problems_path(User.token_authentication_key => current_user.authentication_token, :format => "atom"), :title => "Errbit notices at #{request.host}" |
| 4 | 4 | ||
| 5 | - content_for :action_bar do | 5 | - content_for :action_bar do |
| 6 | - - if @all_errs | 6 | + - if all_errs |
| 7 | = link_to 'hide resolved', problems_path, :class => 'button' | 7 | = link_to 'hide resolved', problems_path, :class => 'button' |
| 8 | - else | 8 | - else |
| 9 | = link_to 'show resolved', problems_path(:all_errs => true), :class => 'button' | 9 | = link_to 'show resolved', problems_path(:all_errs => true), :class => 'button' |
| 10 | 10 | ||
| 11 | %section | 11 | %section |
| 12 | - = render 'problems/search', :all_errs => @all_errs, :app_id => nil | 12 | + = render 'problems/search', :all_errs => all_errs, :app_id => nil |
| 13 | %br | 13 | %br |
| 14 | %section | 14 | %section |
| 15 | #problem_table.problem_table | 15 | #problem_table.problem_table |
spec/views/problems/index.html.haml_spec.rb
| @@ -4,6 +4,7 @@ describe "problems/index.html.haml", type: 'view' do | @@ -4,6 +4,7 @@ describe "problems/index.html.haml", type: 'view' do | ||
| 4 | 4 | ||
| 5 | before do | 5 | before do |
| 6 | allow(view).to receive(:selected_problems).and_return([]) | 6 | allow(view).to receive(:selected_problems).and_return([]) |
| 7 | + allow(view).to receive(:all_errs).and_return(false) | ||
| 7 | allow(view).to receive(:problems).and_return( | 8 | allow(view).to receive(:problems).and_return( |
| 8 | Kaminari.paginate_array([problem_1, problem_2]).page(1).per(10) | 9 | Kaminari.paginate_array([problem_1, problem_2]).page(1).per(10) |
| 9 | ) | 10 | ) |
| @@ -19,4 +20,22 @@ describe "problems/index.html.haml", type: 'view' do | @@ -19,4 +20,22 @@ describe "problems/index.html.haml", type: 'view' do | ||
| 19 | expect(rendered).to have_selector('div#problem_table.problem_table') | 20 | expect(rendered).to have_selector('div#problem_table.problem_table') |
| 20 | end | 21 | end |
| 21 | end | 22 | end |
| 23 | + | ||
| 24 | + describe "show/hide resolved button behavior" do | ||
| 25 | + | ||
| 26 | + it "displays unresolved errors title and button" do | ||
| 27 | + allow(view).to receive(:all_errs).and_return(false) | ||
| 28 | + render | ||
| 29 | + expect(view.content_for(:title)).to match 'Unresolved Errors' | ||
| 30 | + expect(view.content_for(:action_bar)).to have_link 'show resolved' | ||
| 31 | + end | ||
| 32 | + | ||
| 33 | + it "displays all errors title and button" do | ||
| 34 | + allow(view).to receive(:all_errs).and_return(true) | ||
| 35 | + render | ||
| 36 | + expect(view.content_for :title).to match 'All Errors' | ||
| 37 | + expect(view.content_for :action_bar).to have_link 'hide resolved' | ||
| 38 | + end | ||
| 39 | + | ||
| 40 | + end | ||
| 22 | end | 41 | end |