Skip to content

Commit c1d8f96

Browse files
committed
keep org filter (scope) in public search (closes #508)
1 parent 5b05319 commit c1d8f96

File tree

8 files changed

+144
-179
lines changed

8 files changed

+144
-179
lines changed

Gemfile.lock

+81-81
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (6.1.1)
5-
actionpack (= 6.1.1)
6-
activesupport (= 6.1.1)
4+
actioncable (6.1.3)
5+
actionpack (= 6.1.3)
6+
activesupport (= 6.1.3)
77
nio4r (~> 2.0)
88
websocket-driver (>= 0.6.1)
9-
actionmailbox (6.1.1)
10-
actionpack (= 6.1.1)
11-
activejob (= 6.1.1)
12-
activerecord (= 6.1.1)
13-
activestorage (= 6.1.1)
14-
activesupport (= 6.1.1)
9+
actionmailbox (6.1.3)
10+
actionpack (= 6.1.3)
11+
activejob (= 6.1.3)
12+
activerecord (= 6.1.3)
13+
activestorage (= 6.1.3)
14+
activesupport (= 6.1.3)
1515
mail (>= 2.7.1)
16-
actionmailer (6.1.1)
17-
actionpack (= 6.1.1)
18-
actionview (= 6.1.1)
19-
activejob (= 6.1.1)
20-
activesupport (= 6.1.1)
16+
actionmailer (6.1.3)
17+
actionpack (= 6.1.3)
18+
actionview (= 6.1.3)
19+
activejob (= 6.1.3)
20+
activesupport (= 6.1.3)
2121
mail (~> 2.5, >= 2.5.4)
2222
rails-dom-testing (~> 2.0)
23-
actionpack (6.1.1)
24-
actionview (= 6.1.1)
25-
activesupport (= 6.1.1)
23+
actionpack (6.1.3)
24+
actionview (= 6.1.3)
25+
activesupport (= 6.1.3)
2626
rack (~> 2.0, >= 2.0.9)
2727
rack-test (>= 0.6.3)
2828
rails-dom-testing (~> 2.0)
2929
rails-html-sanitizer (~> 1.0, >= 1.2.0)
30-
actiontext (6.1.1)
31-
actionpack (= 6.1.1)
32-
activerecord (= 6.1.1)
33-
activestorage (= 6.1.1)
34-
activesupport (= 6.1.1)
30+
actiontext (6.1.3)
31+
actionpack (= 6.1.3)
32+
activerecord (= 6.1.3)
33+
activestorage (= 6.1.3)
34+
activesupport (= 6.1.3)
3535
nokogiri (>= 1.8.5)
36-
actionview (6.1.1)
37-
activesupport (= 6.1.1)
36+
actionview (6.1.3)
37+
activesupport (= 6.1.3)
3838
builder (~> 3.1)
3939
erubi (~> 1.4)
4040
rails-dom-testing (~> 2.0)
@@ -48,22 +48,22 @@ GEM
4848
kaminari (~> 1.0, >= 1.2.1)
4949
railties (>= 5.2, < 6.2)
5050
ransack (~> 2.1, >= 2.1.1)
51-
activejob (6.1.1)
52-
activesupport (= 6.1.1)
51+
activejob (6.1.3)
52+
activesupport (= 6.1.3)
5353
globalid (>= 0.3.6)
54-
activemodel (6.1.1)
55-
activesupport (= 6.1.1)
56-
activerecord (6.1.1)
57-
activemodel (= 6.1.1)
58-
activesupport (= 6.1.1)
59-
activestorage (6.1.1)
60-
actionpack (= 6.1.1)
61-
activejob (= 6.1.1)
62-
activerecord (= 6.1.1)
63-
activesupport (= 6.1.1)
54+
activemodel (6.1.3)
55+
activesupport (= 6.1.3)
56+
activerecord (6.1.3)
57+
activemodel (= 6.1.3)
58+
activesupport (= 6.1.3)
59+
activestorage (6.1.3)
60+
actionpack (= 6.1.3)
61+
activejob (= 6.1.3)
62+
activerecord (= 6.1.3)
63+
activesupport (= 6.1.3)
6464
marcel (~> 0.3.1)
6565
mimemagic (~> 0.3.2)
66-
activesupport (6.1.1)
66+
activesupport (6.1.3)
6767
concurrent-ruby (~> 1.0, >= 1.0.2)
6868
i18n (>= 1.6, < 2)
6969
minitest (>= 5.1)
@@ -76,8 +76,8 @@ GEM
7676
arbre (1.4.0)
7777
activesupport (>= 3.0.0, < 6.2)
7878
ruby2_keywords (>= 0.0.2, < 1.0)
79-
ast (2.4.1)
80-
autoprefixer-rails (10.2.0.0)
79+
ast (2.4.2)
80+
autoprefixer-rails (10.2.4.0)
8181
execjs
8282
bcrypt (3.1.16)
8383
bindex (0.8.1)
@@ -99,16 +99,16 @@ GEM
9999
capistrano-rbenv (2.2.0)
100100
capistrano (~> 3.1)
101101
sshkit (~> 1.3)
102-
capybara (3.34.0)
102+
capybara (3.35.3)
103103
addressable
104104
mini_mime (>= 0.1.3)
105105
nokogiri (~> 1.8)
106106
rack (>= 1.6.0)
107107
rack-test (>= 0.6.3)
108-
regexp_parser (~> 1.5)
108+
regexp_parser (>= 1.5, < 3.0)
109109
xpath (~> 3.2)
110110
childprocess (3.0.0)
111-
concurrent-ruby (1.1.7)
111+
concurrent-ruby (1.1.8)
112112
connection_pool (2.2.3)
113113
crass (1.0.6)
114114
database_cleaner (1.8.5)
@@ -119,7 +119,7 @@ GEM
119119
responders
120120
warden (~> 1.2.3)
121121
diff-lcs (1.4.4)
122-
docile (1.3.4)
122+
docile (1.3.5)
123123
domain_name (0.5.20190701)
124124
unf (>= 0.0.5, < 1.0.0)
125125
dotenv (2.7.6)
@@ -131,16 +131,16 @@ GEM
131131
tzinfo
132132
execjs (2.7.0)
133133
fabrication (2.21.1)
134-
faker (2.15.1)
134+
faker (2.16.0)
135135
i18n (>= 1.6, < 2)
136136
ffi (1.14.2)
137-
formtastic (3.1.5)
138-
actionpack (>= 3.2.13)
137+
formtastic (4.0.0)
138+
actionpack (>= 5.2.0)
139139
formtastic_i18n (0.6.0)
140-
fugit (1.4.1)
140+
fugit (1.4.2)
141141
et-orbi (~> 1.1, >= 1.1.8)
142142
raabro (~> 1.4)
143-
gli (2.19.2)
143+
gli (2.20.0)
144144
globalid (0.4.2)
145145
activesupport (>= 4.2.0)
146146
has_scope (0.7.2)
@@ -150,7 +150,7 @@ GEM
150150
http-cookie (1.0.3)
151151
domain_name (~> 0.5)
152152
http_accept_language (2.1.1)
153-
i18n (1.8.7)
153+
i18n (1.8.9)
154154
concurrent-ruby (~> 1.0)
155155
inherited_resources (1.12.0)
156156
actionpack (>= 5.2, < 6.2)
@@ -189,7 +189,7 @@ GEM
189189
i18n (>= 0.7, < 2)
190190
json (>= 1.7.7)
191191
rest-client (>= 1.8.0)
192-
loofah (2.8.0)
192+
loofah (2.9.0)
193193
crass (~> 1.0.2)
194194
nokogiri (>= 1.5.9)
195195
mail (2.7.1)
@@ -199,7 +199,7 @@ GEM
199199
method_source (1.0.0)
200200
mime-types (3.3.1)
201201
mime-types-data (~> 3.2015)
202-
mime-types-data (3.2020.1104)
202+
mime-types-data (3.2021.0212)
203203
mimemagic (0.3.5)
204204
mini_mime (1.0.2)
205205
mini_portile2 (2.5.0)
@@ -208,7 +208,7 @@ GEM
208208
net-ssh (>= 2.6.5, < 7.0.0)
209209
net-ssh (6.1.0)
210210
netrc (0.11.0)
211-
nio4r (2.5.4)
211+
nio4r (2.5.5)
212212
nokogiri (1.11.1)
213213
mini_portile2 (~> 2.5.0)
214214
racc (~> 1.4)
@@ -234,20 +234,20 @@ GEM
234234
rack (2.2.3)
235235
rack-test (1.1.0)
236236
rack (>= 1.0, < 3)
237-
rails (6.1.1)
238-
actioncable (= 6.1.1)
239-
actionmailbox (= 6.1.1)
240-
actionmailer (= 6.1.1)
241-
actionpack (= 6.1.1)
242-
actiontext (= 6.1.1)
243-
actionview (= 6.1.1)
244-
activejob (= 6.1.1)
245-
activemodel (= 6.1.1)
246-
activerecord (= 6.1.1)
247-
activestorage (= 6.1.1)
248-
activesupport (= 6.1.1)
237+
rails (6.1.3)
238+
actioncable (= 6.1.3)
239+
actionmailbox (= 6.1.3)
240+
actionmailer (= 6.1.3)
241+
actionpack (= 6.1.3)
242+
actiontext (= 6.1.3)
243+
actionview (= 6.1.3)
244+
activejob (= 6.1.3)
245+
activemodel (= 6.1.3)
246+
activerecord (= 6.1.3)
247+
activestorage (= 6.1.3)
248+
activesupport (= 6.1.3)
249249
bundler (>= 1.15.0)
250-
railties (= 6.1.1)
250+
railties (= 6.1.3)
251251
sprockets-rails (>= 2.0.0)
252252
rails-controller-testing (1.0.5)
253253
actionpack (>= 5.0.1.rc1)
@@ -261,16 +261,16 @@ GEM
261261
rails-i18n (6.0.0)
262262
i18n (>= 0.7, < 2)
263263
railties (>= 6.0.0, < 7)
264-
railties (6.1.1)
265-
actionpack (= 6.1.1)
266-
activesupport (= 6.1.1)
264+
railties (6.1.3)
265+
actionpack (= 6.1.3)
266+
activesupport (= 6.1.3)
267267
method_source
268268
rake (>= 0.8.7)
269269
thor (~> 1.0)
270270
rainbow (3.0.0)
271271
raindrops (0.19.1)
272272
rake (13.0.3)
273-
ransack (2.4.1)
273+
ransack (2.4.2)
274274
activerecord (>= 5.2.4)
275275
activesupport (>= 5.2.4)
276276
i18n
@@ -279,7 +279,7 @@ GEM
279279
ffi (~> 1.0)
280280
rdiscount (2.2.0.2)
281281
redis (4.2.5)
282-
regexp_parser (1.8.2)
282+
regexp_parser (2.0.3)
283283
responders (3.0.1)
284284
actionpack (>= 5.0)
285285
railties (>= 5.0)
@@ -295,7 +295,7 @@ GEM
295295
rspec-expectations (3.10.1)
296296
diff-lcs (>= 1.2.0, < 2.0)
297297
rspec-support (~> 3.10.0)
298-
rspec-mocks (3.10.1)
298+
rspec-mocks (3.10.2)
299299
diff-lcs (>= 1.2.0, < 2.0)
300300
rspec-support (~> 3.10.0)
301301
rspec-rails (4.0.2)
@@ -306,8 +306,8 @@ GEM
306306
rspec-expectations (~> 3.10)
307307
rspec-mocks (~> 3.10)
308308
rspec-support (~> 3.10)
309-
rspec-support (3.10.1)
310-
rubocop (1.8.0)
309+
rspec-support (3.10.2)
310+
rubocop (1.10.0)
311311
parallel (~> 1.10)
312312
parser (>= 3.0.0.0)
313313
rainbow (>= 2.2.2, < 4.0)
@@ -316,14 +316,14 @@ GEM
316316
rubocop-ast (>= 1.2.0, < 2.0)
317317
ruby-progressbar (~> 1.7)
318318
unicode-display_width (>= 1.4.0, < 3.0)
319-
rubocop-ast (1.4.0)
319+
rubocop-ast (1.4.1)
320320
parser (>= 2.7.1.5)
321321
rubocop-rails (2.9.1)
322322
activesupport (>= 4.2.0)
323323
rack (>= 1.1)
324324
rubocop (>= 0.90.0, < 2.0)
325325
ruby-progressbar (1.11.0)
326-
ruby2_keywords (0.0.2)
326+
ruby2_keywords (0.0.4)
327327
rubyzip (2.3.0)
328328
sassc (2.4.0)
329329
ffi (~> 1.9)
@@ -337,9 +337,9 @@ GEM
337337
selenium-webdriver (3.142.7)
338338
childprocess (>= 0.5, < 4.0)
339339
rubyzip (>= 1.2.2)
340-
shoulda-matchers (4.4.1)
340+
shoulda-matchers (4.5.1)
341341
activesupport (>= 4.2.0)
342-
sidekiq (6.1.2)
342+
sidekiq (6.1.3)
343343
connection_pool (>= 2.2.2)
344344
rack (~> 2.0)
345345
redis (>= 4.2.0)
@@ -349,7 +349,7 @@ GEM
349349
simple_form (5.0.3)
350350
actionpack (>= 5.0)
351351
activemodel (>= 5.0)
352-
simplecov (0.21.1)
352+
simplecov (0.21.2)
353353
docile (~> 1.1)
354354
simplecov-html (~> 0.11)
355355
simplecov_json_formatter (~> 0.1)
@@ -366,10 +366,10 @@ GEM
366366
actionpack (>= 4.0)
367367
activesupport (>= 4.0)
368368
sprockets (>= 3.0.0)
369-
sshkit (1.21.1)
369+
sshkit (1.21.2)
370370
net-scp (>= 1.1.2)
371371
net-ssh (>= 2.8.0)
372-
thor (1.0.1)
372+
thor (1.1.0)
373373
tilt (2.0.10)
374374
ttfunk (1.7.0)
375375
tzinfo (2.0.4)
@@ -390,7 +390,7 @@ GEM
390390
activemodel (>= 6.0.0)
391391
bindex (>= 0.4.0)
392392
railties (>= 6.0.0)
393-
webdrivers (4.4.2)
393+
webdrivers (4.5.0)
394394
nokogiri (~> 1.6)
395395
rubyzip (>= 1.3.0)
396396
selenium-webdriver (>= 3.0, < 4.0)

app/controllers/posts_controller.rb

+4-8
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@ class PostsController < ApplicationController
55

66
def index
77
context = model.active.of_active_members
8+
89
if current_organization.present?
910
context = context.where(
1011
organization_id: current_organization.id
1112
)
1213
end
1314

14-
posts = if (query = params[:q]).present?
15-
context.
16-
search_by_query(query).
17-
page(params[:page]).
18-
per(25)
19-
else
20-
apply_scopes(context).page(params[:page]).per(25)
21-
end
15+
posts = apply_scopes(context)
16+
posts = posts.search_by_query(params[:q]) if params[:q].present?
17+
posts = posts.page(params[:page]).per(25)
2218

2319
instance_variable_set("@#{resources}", posts)
2420
end

0 commit comments

Comments
 (0)