require 'spec_helper' describe ApiRetailerInvitationsController, type: :controller do render_views let (:owner) {FactoryGirl.create(:user)} let (:retailer) {FactoryGirl.create(:retailer, user: owner)} let (:retailer_invitation_teacher) {FactoryGirl.create(:retailer_invitation, retailer: retailer)} before(:each) do controller.current_user = owner end describe "index" do it "works" do get :index, id: retailer.id response.should be_success JSON.parse(response.body)['total_entries'].should eql 0 retailer_invitation_teacher.touch get :index, id: retailer.id response.should be_success JSON.parse(response.body)['total_entries'].should eql 1 end end describe "create" do it "works" do UserMailer.deliveries.clear post :create, id: retailer.id, first_name: "Seth", last_name: "Call", email: "seth@jamkazam.com", :format => 'json' response.should be_success UserMailer.deliveries.length.should eql 1 JSON.parse(response.body)['id'].should eql RetailerInvitation.find_by_email("seth@jamkazam.com").id end end describe "resend" do it "works" do UserMailer.deliveries.clear post :resend, id: retailer.id, invitation_id: retailer_invitation_teacher.id, :format => 'json' UserMailer.deliveries.length.should eql 1 response.should be_success end end describe "delete" do it "works" do delete :delete, id: retailer.id, invitation_id: retailer_invitation_teacher.id, :format => 'json' response.should be_success end end end