Sha256: be2e79738da98e3511f61101b360d56daccecf7ece10de99058628e1c3dd4cc3
Contents?: true
Size: 1.34 KB
Versions: 8
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' describe FeaturedWorksController do describe "#create" do before do sign_in FactoryGirl.create(:user) expect(controller).to receive(:authorize!).with(:create, FeaturedWork).and_return(true) end context "when there are no featured works" do it "should create one" do expect { post :create, id: '1234abcd', format: :json }.to change { FeaturedWork.count}.by(1) expect(response).to be_successful end end context "when there are 5 featured works" do before do 5.times do |n| FeaturedWork.create(generic_file_id:n.to_s) end end it "should not create another" do expect { post :create, id: '1234abcd', format: :json }.to_not change { FeaturedWork.count} expect(response.status).to eq 422 end end end describe "#destroy" do let!(:featured_work) { FactoryGirl.create(:featured_work, generic_file_id: '1234abcd') } before do sign_in FactoryGirl.create(:user) expect(controller).to receive(:authorize!).with(:destroy, FeaturedWork).and_return(true) end it "should remove it" do expect { delete :destroy, id: '1234abcd', format: :json }.to change { FeaturedWork.count}.by(-1) expect(response.status).to eq 204 end end end
Version data entries
8 entries across 8 versions & 1 rubygems