Sha256: 354d8d06c46c9db8d5386304647510506d1da570fb6c4d0a095cf24d4224ca0f

Contents?: true

Size: 1.85 KB

Versions: 60

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'

describe Dorsale::Flyboy::TaskComment do
  it { is_expected.to belong_to(:task) }

  it { is_expected.to validate_presence_of :task }
  it { is_expected.to validate_presence_of :date }
  it { is_expected.to validate_presence_of :description }

  it { is_expected.to belong_to :author }
  it { is_expected.to validate_presence_of :author }

  it 'should have a valid factory' do
    expect(build(:flyboy_task_comment)).to be_valid
  end

  it 'should update the task progress upon creation' do
    task    = create(:flyboy_task, progress: 10)
    comment = create(:flyboy_task_comment, progress: 20, task: task)
    expect(task.reload.progress).to eq(20)
  end

  it 'should mark task as complete when progress == 100' do
    task    = create(:flyboy_task, progress: 10, done: false)
    comment = create(:flyboy_task_comment, progress: 100, task: task)
    expect(task.reload.done).to be true
  end

  it 'should mark task as un complete when progress < 100' do
    task    = create(:flyboy_task, progress: 100, done: true)
    comment = create(:flyboy_task_comment, progress: 90, task: task)
    expect(task.reload.done).to be false
  end

  describe "default values" do
    it "#new progress should be 0 if no task" do
      expect(Dorsale::Flyboy::TaskComment.new.progress).to eq 0
    end

    it "#new progress should be task progress if task specified" do
      task = create(:flyboy_task, progress: 50)
      expect(task.comments.new.progress).to eq 50
    end

    it "#new progress should not override exisring progress" do
      task = create(:flyboy_task)
      comment1 = create(:flyboy_task_comment, task: task, progress: 30)
      comment2 = create(:flyboy_task_comment, task: task, progress: 50)
      expect(task.reload.progress).to eq 50
      expect(comment1.reload.progress).to eq 30
      expect(comment2.reload.progress).to eq 50
    end

  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
dorsale-2.2.3 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.2.2 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.2.1 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.2.0 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.15 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.14 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.13 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.12 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.11 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.10 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.9 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.8 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.7 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.6 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.5 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.4 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.3 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.2 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.1 spec/models/dorsale/flyboy/task_comment_spec.rb
dorsale-2.1.0 spec/models/dorsale/flyboy/task_comment_spec.rb