aboutsummaryrefslogtreecommitdiff
path: root/test/system/shared_searches_test.rb
blob: 6828dbe1e5bf98ef057f8f2e6a2cd45a8755a55e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

require 'application_system_test_case'

class SharedSearchesTest < ApplicationSystemTestCase
  test 'can access shared_searches#index from the hidden menu' do
    sign_in!

    find('#toggle-hidden-global-menu').click

    assert_text I18n.t('searches.shared.title').downcase

    click_on I18n.t('searches.shared.title').downcase

    assert_text I18n.t('searches.shared.none')
  end

  test 'cannot access shared_searches#index if not logged in' do
    sign_out_maybe!

    visit shared_searches_path

    assert_text I18n.t('sessions.title')
    assert_equal page.current_path, new_sessions_path
  end

  test 'shared_searches#show gives us the expected results' do
    # NOTE: not logged in!

    searches(:search1).update!(shared: true)

    visit search_shared_path(searches(:search1))

    assert_text things(:thing1).title
    assert_text things(:thing2).title
    assert_text I18n.t('comments.title')
  end
end