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,8 +88,7 @@ | ||
88 | - if app.problems.any? | 88 | - if app.problems.any? |
89 | %h3.clear=t('.errors') | 89 | %h3.clear=t('.errors') |
90 | %section | 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 | %br | 92 | %br |
94 | %section | 93 | %section |
95 | .problem_table{:id => 'problem_table'} | 94 | .problem_table{:id => 'problem_table'} |
app/views/problems/index.html.haml
@@ -9,8 +9,7 @@ | @@ -9,8 +9,7 @@ | ||
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 | - = 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 | %br | 13 | %br |
15 | %section | 14 | %section |
16 | #problem_table.problem_table | 15 | #problem_table.problem_table |
config/locales/en.yml
@@ -77,6 +77,8 @@ en: | @@ -77,6 +77,8 @@ en: | ||
77 | merge: "Merge select issues? They can be unmerged later." | 77 | merge: "Merge select issues? They can be unmerged later." |
78 | unmerge: "Unmerge selected issues? They can be re-merged later." | 78 | unmerge: "Unmerge selected issues? They can be re-merged later." |
79 | unresolve: "Unresolve selected issues? They can be resolved again later." | 79 | unresolve: "Unresolve selected issues? They can be resolved again later." |
80 | + search: | ||
81 | + search_placeholder: 'Search for issues' | ||
80 | 82 | ||
81 | comments: | 83 | comments: |
82 | confirm_delete: "Permanently delete this comment?" | 84 | confirm_delete: "Permanently delete this comment?" |
@@ -118,7 +120,6 @@ en: | @@ -118,7 +120,6 @@ en: | ||
118 | no_watcher: "Sadly, no one is watching this app" | 120 | no_watcher: "Sadly, no one is watching this app" |
119 | repository: Repository | 121 | repository: Repository |
120 | revision: Revision | 122 | revision: Revision |
121 | - search_placeholder: 'Search for issues' | ||
122 | show_hide: "(show/hide)" | 123 | show_hide: "(show/hide)" |
123 | unresolved_errs: unresolved errs | 124 | unresolved_errs: unresolved errs |
124 | unwatch: unwatch | 125 | unwatch: unwatch |
spec/controllers/problems_controller_spec.rb
@@ -123,6 +123,31 @@ describe ProblemsController do | @@ -123,6 +123,31 @@ describe ProblemsController do | ||
123 | end | 123 | end |
124 | end | 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 | describe "GET /apps/:app_id/problems/:id" do | 151 | describe "GET /apps/:app_id/problems/:id" do |
127 | #render_views | 152 | #render_views |
128 | 153 |