Sha256: 1f4cc9b1d8ceae4ced21c6ae9891f9877d02d1f364a1310b386b8467e7176e31

Contents?: true

Size: 894 Bytes

Versions: 4

Compression:

Stored size: 894 Bytes

Contents

require 'rails_helper'

RSpec.describe "Unsakini::Board::Post::Comments", type: :request do

  before(:all) do
    post_has_many_comments_scenario
  end

  let(:num_per_page) {
    20
  }

  describe "Pagination" do

    it "returns first 20 comments" do
      get unsakini_board_post_comments_path(@board, @post), headers: auth_headers(@user), params: {page: 1}
      expect(body_to_json.count).to eq num_per_page
      expect(body_to_json('0')).to match_json_schema(:comment)
      expect(get_header("Total").to_i).to eq @num_comments
    end

    it "returns last page" do
      get unsakini_board_post_comments_path(@board, @post), headers: auth_headers(@user), params: {page: 2}
      expect(body_to_json('0')).to match_json_schema(:comment)
      expect(get_header("Total").to_i).to eq @num_comments
      expect(body_to_json.count).to eq @num_comments - num_per_page
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unsakini-0.0.5 spec/requests/comments/comments_pagination_spec.rb
unsakini-0.0.5.pre.1 spec/requests/comments/comments_pagination_spec.rb
unsakini-0.0.4.pre.1 spec/requests/comments/comments_pagination_spec.rb
unsakini-0.0.4.3 spec/requests/comments/comments_pagination_spec.rb