spec/serializable/paging_spec.rb in restpack_serializer-0.4.2 vs spec/serializable/paging_spec.rb in restpack_serializer-0.4.3

- old
+ new

@@ -5,11 +5,11 @@ @album1 = FactoryGirl.create(:album_with_songs, song_count: 11) @album2 = FactoryGirl.create(:album_with_songs, song_count: 7) end context "#page" do - let(:page) { SongSerializer.page(params) } + let(:page) { MyApp::SongSerializer.page(params) } let(:params) { { } } context "with defaults" do it "page defaults to 1" do page[:meta][:songs][:page].should == 1 @@ -44,11 +44,11 @@ page[:meta][:songs][:next_href].should == '/songs.json?page=2&page_size=3' end end it "serializes results" do - first = Song.first + first = MyApp::Song.first page[:songs].first.should == { id: first.id.to_s, title: first.title, album_id: first.album_id, links: { @@ -143,23 +143,23 @@ context "with custom scope" do before do FactoryGirl.create(:album, year: 1930) FactoryGirl.create(:album, year: 1948) end - let(:page) { AlbumSerializer.page(params, scope) } - let(:scope) { Album.classic } + let(:page) { MyApp::AlbumSerializer.page(params, scope) } + let(:scope) { MyApp::Album.classic } it "returns a page of scoped data" do page[:meta][:albums][:count].should == 2 end end end context "#page_with_options" do - let(:page) { SongSerializer.page_with_options(options) } + let(:page) { MyApp::SongSerializer.page_with_options(options) } let(:params) { {} } - let(:options) { RestPack::Serializer::Options.new(SongSerializer, params) } + let(:options) { RestPack::Serializer::Options.new(MyApp::SongSerializer, params) } context "with defaults" do it "includes valid paging meta data" do page[:meta][:songs][:count].should == 18 page[:meta][:songs][:page_count].should == 2 @@ -176,23 +176,23 @@ end end end context "paging with paged side-load" do - let(:page) { AlbumSerializer.page_with_options(options) } - let(:options) { RestPack::Serializer::Options.new(AlbumSerializer, { includes: 'songs' }) } + let(:page) { MyApp::AlbumSerializer.page_with_options(options) } + let(:options) { RestPack::Serializer::Options.new(MyApp::AlbumSerializer, { includes: 'songs' }) } it "includes side-loaded paging data in meta data" do page[:meta][:albums].should_not == nil page[:meta][:albums][:page].should == 1 page[:meta][:songs].should_not == nil page[:meta][:songs][:page].should == 1 end end context "paging with two paged side-loads" do - let(:page) { ArtistSerializer.page_with_options(options) } - let(:options) { RestPack::Serializer::Options.new(ArtistSerializer, { includes: 'albums,songs' }) } + let(:page) { MyApp::ArtistSerializer.page_with_options(options) } + let(:options) { RestPack::Serializer::Options.new(MyApp::ArtistSerializer, { includes: 'albums,songs' }) } it "includes side-loaded paging data in meta data" do page[:meta][:albums].should_not == nil page[:meta][:albums][:page].should == 1 page[:meta][:songs].should_not == nil