Commit 4a3a6052cbf2b9e98e6544cc8909b0bef8c2516a

Authored by Stephen Crosby
2 parents 0967e163 4eab7430
Exists in master and in 1 other branch production

Merge pull request #985 from meh-/errors_page_show_resolved_button_fix

fixed button 'show/hide resolved' on errors#index page
app/views/apps/show.html.haml
... ... @@ -91,7 +91,7 @@
91 91 - if app.problems.any?
92 92 %h3.clear=t('.errors')
93 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 95 %br
96 96 %section
97 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 2 - content_for :head do
3 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 5 - content_for :action_bar do
6   - - if @all_errs
  6 + - if all_errs
7 7 = link_to 'hide resolved', problems_path, :class => 'button'
8 8 - else
9 9 = link_to 'show resolved', problems_path(:all_errs => true), :class => 'button'
10 10  
11 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 13 %br
14 14 %section
15 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 4  
5 5 before do
6 6 allow(view).to receive(:selected_problems).and_return([])
  7 + allow(view).to receive(:all_errs).and_return(false)
7 8 allow(view).to receive(:problems).and_return(
8 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 20 expect(rendered).to have_selector('div#problem_table.problem_table')
20 21 end
21 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 41 end
... ...