Sha256: 8b87c5e8ae306c4c67c77053a7273fe8989366bfabfdb1f2dcc36243baf29007
Contents?: true
Size: 1.36 KB
Versions: 13
Compression:
Stored size: 1.36 KB
Contents
require 'spec_helper' describe FeaturedWorksController, :type => :controller 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
13 entries across 13 versions & 1 rubygems