-
-
Save plainprogrammer/0cf56d3b3fe02e6c96d0e09b95fedb01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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