Commit 47e7cefd5c7c5b301507e9cbf0dcb04b15d8e219
Exists in
master
and in
1 other branch
Merge pull request #747 from robinboening/feature/date_filter
Render partial for problems/search form and add specs
Showing
5 changed files
with
31 additions
and
5 deletions
Show diff stats
app/views/apps/show.html.haml
| ... | ... | @@ -88,8 +88,7 @@ |
| 88 | 88 | - if app.problems.any? |
| 89 | 89 | %h3.clear=t('.errors') |
| 90 | 90 | %section |
| 91 | - = form_tag search_problems_path(:all_errs => all_errs, :app_id => app.id), :method => :get, :remote => true do | |
| 92 | - = text_field_tag :search, params[:search], :placeholder => t('.search_placeholder') | |
| 91 | + = render 'problems/search', :all_errs => @all_errs, :app_id => app.id | |
| 93 | 92 | %br |
| 94 | 93 | %section |
| 95 | 94 | .problem_table{:id => 'problem_table'} | ... | ... |
app/views/problems/index.html.haml
| ... | ... | @@ -9,8 +9,7 @@ |
| 9 | 9 | = link_to 'show resolved', problems_path(:all_errs => true), :class => 'button' |
| 10 | 10 | |
| 11 | 11 | %section |
| 12 | - = form_tag search_problems_path(:all_errs => @all_errs), :method => :get, :remote => true do | |
| 13 | - = text_field_tag :search, params[:search], :placeholder => 'Search for issues' | |
| 12 | + = render 'problems/search', :all_errs => @all_errs, :app_id => nil | |
| 14 | 13 | %br |
| 15 | 14 | %section |
| 16 | 15 | #problem_table.problem_table | ... | ... |
config/locales/en.yml
| ... | ... | @@ -77,6 +77,8 @@ en: |
| 77 | 77 | merge: "Merge select issues? They can be unmerged later." |
| 78 | 78 | unmerge: "Unmerge selected issues? They can be re-merged later." |
| 79 | 79 | unresolve: "Unresolve selected issues? They can be resolved again later." |
| 80 | + search: | |
| 81 | + search_placeholder: 'Search for issues' | |
| 80 | 82 | |
| 81 | 83 | comments: |
| 82 | 84 | confirm_delete: "Permanently delete this comment?" |
| ... | ... | @@ -118,7 +120,6 @@ en: |
| 118 | 120 | no_watcher: "Sadly, no one is watching this app" |
| 119 | 121 | repository: Repository |
| 120 | 122 | revision: Revision |
| 121 | - search_placeholder: 'Search for issues' | |
| 122 | 123 | show_hide: "(show/hide)" |
| 123 | 124 | unresolved_errs: unresolved errs |
| 124 | 125 | unwatch: unwatch | ... | ... |
spec/controllers/problems_controller_spec.rb
| ... | ... | @@ -123,6 +123,31 @@ describe ProblemsController do |
| 123 | 123 | end |
| 124 | 124 | end |
| 125 | 125 | |
| 126 | + describe "GET /problems/search" do | |
| 127 | + before do | |
| 128 | + sign_in Fabricate(:admin) | |
| 129 | + @app = Fabricate(:app) | |
| 130 | + @problem1 = Fabricate(:problem, :app=>@app, message: "Most important") | |
| 131 | + @problem2 = Fabricate(:problem, :app=>@app, message: "Very very important") | |
| 132 | + end | |
| 133 | + | |
| 134 | + it "renders successfully" do | |
| 135 | + get :search | |
| 136 | + expect(response).to be_success | |
| 137 | + end | |
| 138 | + | |
| 139 | + it "renders index template" do | |
| 140 | + get :search | |
| 141 | + expect(response).to render_template('problems/index') | |
| 142 | + end | |
| 143 | + | |
| 144 | + it "searches problems for given string" do | |
| 145 | + get :search, :search => "Most important" | |
| 146 | + expect(controller.problems).to include(@problem1) | |
| 147 | + expect(controller.problems).to_not include(@problem2) | |
| 148 | + end | |
| 149 | + end | |
| 150 | + | |
| 126 | 151 | describe "GET /apps/:app_id/problems/:id" do |
| 127 | 152 | #render_views |
| 128 | 153 | ... | ... |