spec/models/flyboy/goal_spec.rb in flyboy-1.0.7 vs spec/models/flyboy/goal_spec.rb in flyboy-1.1.0
- old
+ new
@@ -2,11 +2,11 @@
describe Flyboy::Goal do
it { should have_many(:tasks).dependent(:destroy) }
describe '#validation' do
- it { should validate_presence_of :title }
+ it { should validate_presence_of :name }
it "should validate the goal when not step is assigned" do
goal = FactoryGirl.build(:flyboy_goal)
expect(goal).to be_valid
end
@@ -45,21 +45,21 @@
end
describe "#progress" do
it "update task should update goal progress" do
goal = FactoryGirl.create(:flyboy_goal)
- task1 = FactoryGirl.create(:flyboy_task, goal: goal, progress: 50)
- task2 = FactoryGirl.create(:flyboy_task, goal: goal, progress: 100)
+ task1 = FactoryGirl.create(:flyboy_task, taskable: goal, progress: 50)
+ task2 = FactoryGirl.create(:flyboy_task, taskable: goal, progress: 100)
expect(goal.reload.progress).to eq 75
task1.progress = 100
task1.save
expect(goal.reload.progress).to eq 100
end
it "delete task should update goal progress" do
goal = FactoryGirl.create(:flyboy_goal)
- task1 = FactoryGirl.create(:flyboy_task, goal: goal, progress: 50)
+ task1 = FactoryGirl.create(:flyboy_task, taskable: goal, progress: 50)
expect(goal.reload.progress).to eq 50
task1.destroy
expect(goal.reload.progress).to eq 0
end
@@ -85,17 +85,17 @@
expect(goal.status).to eq "open"
end
it "open goal with undone tasks can't be closed" do
goal = FactoryGirl.create(:flyboy_goal, status: "open")
- task = FactoryGirl.create(:flyboy_task, goal: goal, done: false)
+ task = FactoryGirl.create(:flyboy_task, taskable: goal, done: false)
expect(goal.close).to be false
expect(goal.status).to eq "open"
end
it "open goal with all tasks done can be closed" do
goal = FactoryGirl.create(:flyboy_goal, status: "open")
- task = FactoryGirl.create(:flyboy_task, goal: goal, done: true)
+ task = FactoryGirl.create(:flyboy_task, taskable: goal, done: true)
expect(goal.close).to be true
expect(goal.status).to eq "closed"
end
end