diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-28 13:07:30 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-28 13:07:30 +0100 |
commit | f4315b725bf8bb4dbf3672a817761ce1eaf033a7 (patch) | |
tree | 9f3c09f56b0c20d39548048534055625f67f1229 /app/serializers | |
parent | 5838b1602452c0f2214f76e2f84f202e9067c20b (diff) | |
download | gitlab-ce-f4315b725bf8bb4dbf3672a817761ce1eaf033a7.tar.gz |
Add specs for pipeline serializer with pagination
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/pipeline_serializer.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb index 76c767f82c0..2de34758f1f 100644 --- a/app/serializers/pipeline_serializer.rb +++ b/app/serializers/pipeline_serializer.rb @@ -1,17 +1,20 @@ class PipelineSerializer < BaseSerializer entity PipelineEntity + class InvalidResourceError < StandardError; end include API::Helpers::Pagination Struct.new('Pagination', :request, :response) def represent(resource, opts = {}) - if paginate? + if paginated? + raise InvalidResourceError unless resource.respond_to?(:page) + super(paginate(resource), opts) else super(resource, opts) end end - def paginate? + def paginated? defined?(@pagination) end |