diff options
author | Stan Hu <stanhu@gmail.com> | 2018-08-30 23:39:56 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-09-04 08:37:36 +0300 |
commit | b9cee4ba3c5e22766de771edde2b8d523ee84993 (patch) | |
tree | 8cfdcb02f48d8ccf1b15e55069829c0d2d4d045d /spec/controllers/concerns | |
parent | ba99dfcde262c91e33b5bf7f86ba7c0e3b6f7e52 (diff) |
Set issuable_sort and diff_view cookies to secure when possible
Closes #49120
Diffstat (limited to 'spec/controllers/concerns')
-rw-r--r-- | spec/controllers/concerns/issuable_collections_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/controllers/concerns/issuable_collections_spec.rb b/spec/controllers/concerns/issuable_collections_spec.rb index c1f42bbb9d7..d16a3464495 100644 --- a/spec/controllers/concerns/issuable_collections_spec.rb +++ b/spec/controllers/concerns/issuable_collections_spec.rb @@ -21,6 +21,34 @@ describe IssuableCollections do controller end + describe '#set_set_order_from_cookie' do + describe 'when sort param given' do + let(:cookies) { {} } + let(:params) { { sort: 'downvotes_asc' } } + + it 'sets the cookie with the right values and flags' do + allow(controller).to receive(:cookies).and_return(cookies) + + controller.send(:set_sort_order_from_cookie) + + expect(cookies['issue_sort']).to eq({ value: 'popularity', secure: false, httponly: false }) + end + end + + describe 'when cookie exists' do + let(:cookies) { { 'issue_sort' => 'id_asc' } } + let(:params) { {} } + + it 'sets the cookie with the right values and flags' do + allow(controller).to receive(:cookies).and_return(cookies) + + controller.send(:set_sort_order_from_cookie) + + expect(cookies['issue_sort']).to eq({ value: 'created_asc', secure: false, httponly: false }) + end + end + end + describe '#page_count_for_relation' do let(:params) { { state: 'opened' } } |