From 4eab743095448859c828a0466d4466b38797a969 Mon Sep 17 00:00:00 2001 From: d.yakovlev Date: Thu, 29 Oct 2015 02:16:52 +0500 Subject: [PATCH] fixed button 'show/hide resolved' on errors#index page --- app/views/apps/show.html.haml | 2 +- app/views/problems/index.html.haml | 6 +++--- spec/views/problems/index.html.haml_spec.rb | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/views/apps/show.html.haml b/app/views/apps/show.html.haml index afdd893..4092191 100644 --- a/app/views/apps/show.html.haml +++ b/app/views/apps/show.html.haml @@ -91,7 +91,7 @@ - if app.problems.any? %h3.clear=t('.errors') %section - = render 'problems/search', :all_errs => @all_errs, :app_id => app.id + = render 'problems/search', :all_errs => all_errs, :app_id => app.id %br %section .problem_table{:id => 'problem_table'} diff --git a/app/views/problems/index.html.haml b/app/views/problems/index.html.haml index 3a4c369..164e2d8 100644 --- a/app/views/problems/index.html.haml +++ b/app/views/problems/index.html.haml @@ -1,15 +1,15 @@ -- content_for :title, @all_errs ? 'All Errors' : 'Unresolved Errors' +- content_for :title, all_errs ? 'All Errors' : 'Unresolved Errors' - content_for :head do = auto_discovery_link_tag :atom, problems_path(User.token_authentication_key => current_user.authentication_token, :format => "atom"), :title => "Errbit notices at #{request.host}" - content_for :action_bar do - - if @all_errs + - if all_errs = link_to 'hide resolved', problems_path, :class => 'button' - else = link_to 'show resolved', problems_path(:all_errs => true), :class => 'button' %section - = render 'problems/search', :all_errs => @all_errs, :app_id => nil + = render 'problems/search', :all_errs => all_errs, :app_id => nil %br %section #problem_table.problem_table diff --git a/spec/views/problems/index.html.haml_spec.rb b/spec/views/problems/index.html.haml_spec.rb index c6d0f53..f2c32e5 100644 --- a/spec/views/problems/index.html.haml_spec.rb +++ b/spec/views/problems/index.html.haml_spec.rb @@ -4,6 +4,7 @@ describe "problems/index.html.haml", type: 'view' do before do allow(view).to receive(:selected_problems).and_return([]) + allow(view).to receive(:all_errs).and_return(false) allow(view).to receive(:problems).and_return( Kaminari.paginate_array([problem_1, problem_2]).page(1).per(10) ) @@ -19,4 +20,22 @@ describe "problems/index.html.haml", type: 'view' do expect(rendered).to have_selector('div#problem_table.problem_table') end end + + describe "show/hide resolved button behavior" do + + it "displays unresolved errors title and button" do + allow(view).to receive(:all_errs).and_return(false) + render + expect(view.content_for(:title)).to match 'Unresolved Errors' + expect(view.content_for(:action_bar)).to have_link 'show resolved' + end + + it "displays all errors title and button" do + allow(view).to receive(:all_errs).and_return(true) + render + expect(view.content_for :title).to match 'All Errors' + expect(view.content_for :action_bar).to have_link 'hide resolved' + end + + end end -- libgit2 0.21.2