Sha256: cc56d8e12258c8b7dd4a086155a1b2c78ef10c4b6f50eb97ed34247c66c0a753
Contents?: true
Size: 1.43 KB
Versions: 10
Compression:
Stored size: 1.43 KB
Contents
require "spec_helper" module BitCore describe Slideshow do fixtures :"bit_core/slideshows", :"bit_core/slides" let(:slideshow) { bit_core_slideshows(:slideshow1) } describe "#add" do it "should return a slide with its position set to the end" do new_slide = slideshow.add(title: "New", body: "Slide") expect(new_slide.valid?).to be_truthy expect(new_slide.position).to eq 4 end end describe "#remove" do it "should update remaining slide positions" do result = slideshow.remove(bit_core_slides(:slide2)) expect(result).to be_truthy expect(slideshow.slides.count).to eq 2 expect(slideshow.slides.first.id).to eq bit_core_slides(:slide1).id expect(slideshow.slides.first.position).to eq 1 expect(slideshow.slides.second.id).to eq bit_core_slides(:slide3).id expect(slideshow.slides.second.position).to eq 2 end end describe "#sort" do it "should update slide positions to match the order of the ids" do slide1 = bit_core_slides(:slide1) slide2 = bit_core_slides(:slide2) slide3 = bit_core_slides(:slide3) slideshow.sort([slide3.id, slide1.id, slide2.id]) expect(slideshow.slides.find(slide1.id).position).to eq(2) expect(slideshow.slides.find(slide2.id).position).to eq(3) expect(slideshow.slides.find(slide3.id).position).to eq(1) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems