From f1926b321deb8b922dead991fb4d8bea42699f9f Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Tue, 3 Sep 2019 19:45:00 +0200 Subject: Add controller concern for paginated collections We had similar code in a few places to redirect to the last page if the given page number is out of range. This unifies the handling in a new controller concern and adds usage of it in all snippet listings. --- .../dashboard/snippets_controller_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/controllers/dashboard/snippets_controller_spec.rb (limited to 'spec/controllers/dashboard/snippets_controller_spec.rb') diff --git a/spec/controllers/dashboard/snippets_controller_spec.rb b/spec/controllers/dashboard/snippets_controller_spec.rb new file mode 100644 index 00000000000..2d839094d34 --- /dev/null +++ b/spec/controllers/dashboard/snippets_controller_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Dashboard::SnippetsController do + let(:user) { create(:user) } + + before do + sign_in(user) + end + + describe 'GET #index' do + it_behaves_like 'paginated collection' do + let(:collection) { Snippet.all } + + before do + create(:personal_snippet, :public, author: user) + end + end + end +end -- cgit v1.2.1