mahi-man
mahi-man

Reputation: 4686

Rspec Rails Testing for PublicActivity creation in controller test

I am testing the update method of a controller and part of the update creates a custom activity using the PublicActivity gem. When testing in Rspec the activities do not seem to be created. Here is the test that is failing:

it "creates a shared activity" do
      PublicActivity.with_tracking do
        expect{
            put :update, user_id: @michael, id: @michaels_task, task: FactoryGirl.attributes_for(:task, users_shared_to_ids: [@archer.id])
          }.to change(PublicActivity::Activity,:count).by(1)
      end
    end

I know that the put :update line works correctly as I can pass other tests looking for other changes relating to sharing the task.

Upvotes: 0

Views: 246

Answers (1)

mahi-man
mahi-man

Reputation: 4686

It was just me being stupid sorry. Activity was being created only in the format.js section, I.e. I just needed to change to xhr :put, :update, ... Thanks.

Upvotes: 1

Related Questions