Skip to content

Instantly share code, notes, and snippets.

@plainprogrammer plainprogrammer/task_spec.rb Secret
Created Aug 29, 2017

Embed
What would you like to do?
describe Task do
describe "#reset" do
subject { build :task, started_at: past_timestamp, completed_at: past_timestamp, failed_at: past_timestamp }
let(:past_timestamp) { 3.weeks.ago }
it "resets the started_at timestamp to now" do
expect { subject.reset }.to change { subject.started_at }.from(past_timestamp).to(DateTime.now)
end
it "clears the completed_at timestamp" do
expect { subject.reset }.to change { subject.completed_at }.from(past_timestamp).to(nil)
end
it "clears the failed_at timestamp" do
expect { subject.reset }.to change { subject.failed_at }.from(past_timestamp).to(nil)
end
it "destroys all associated TaskActions" do
expect { subject.reset }.to change { subject.task_actions.count }.from(2).to(0)
end
it "resets completion state for all associated FeedItems" do
expect { subject.reset }.to change { FeedItems.for(subject).completed.count }.from(3).to(0)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.