Skip to content

Commit

Permalink
Merge pull request #11763 from opf/refactor-use_be_writable
Browse files Browse the repository at this point in the history
Use be_writable instead of writable? in specs
  • Loading branch information
ulferts committed Dec 6, 2022
2 parents e007f4f + f726994 commit dd46754
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.
Expand Up @@ -53,7 +53,11 @@
end

it "is #{'not' unless writable} writable" do
expect(subject.writable?(:version)).to eql(writable)
if writable
expect(subject).to be_writable(:version)
else
expect(subject).not_to be_writable(:version)
end
end
end

Expand All @@ -66,7 +70,7 @@
end

it "is writable" do
expect(subject.writable?(:version)).to be(true)
expect(subject).to be_writable(:version)
end
end

Expand All @@ -83,7 +87,7 @@
end

it 'is writable' do
expect(subject.writable?(:remaining_hours)).to be(true)
expect(subject).to be_writable(:remaining_hours)
end
end

Expand All @@ -93,7 +97,7 @@
end

it 'is not writable' do
expect(subject.writable?(:remaining_hours)).to be(false)
expect(subject).not_to be_writable(:remaining_hours)
end
end
end
Expand Down
Expand Up @@ -66,17 +66,17 @@

context 'if the user has the :manage_dashboards permission' do
it 'is truthy' do
expect(described_class.writable?(grid, user))
.to be_truthy
expect(described_class)
.to be_writable(grid, user)
end
end

context 'if the user lacks the :manage_dashboards permission' do
let(:allowed) { false }

it 'is falsey' do
expect(described_class.writable?(grid, user))
.to be_falsey
expect(described_class)
.not_to be_writable(grid, user)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/constants/settings/definition_spec.rb
Expand Up @@ -909,8 +909,8 @@ def value_for(name)
end

it 'returns the procs return value for writable' do
expect(instance.writable?)
.to be false
expect(instance)
.not_to be_writable
end

it 'returns the procs return value for allowed' do
Expand Down
Expand Up @@ -176,46 +176,46 @@
context 'percentage done' do
it 'is not writable when inferred by status' do
allow(Setting).to receive(:work_package_done_ratio).and_return('status')
expect(subject.writable?('done_ratio')).to be false
expect(subject).not_to be_writable(:done_ratio)
end

it 'is not writable when disabled' do
allow(Setting).to receive(:work_package_done_ratio).and_return('disabled')
expect(subject.writable?('done_ratio')).to be false
expect(subject).not_to be_writable(:done_ratio)
end

it 'is not writable when the work package is a parent' do
allow(work_package).to receive(:leaf?).and_return(false)
expect(subject.writable?('done_ratio')).to be false
expect(subject).not_to be_writable(:done_ratio)
end

it 'is writable when the work package is a leaf' do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject.writable?('done_ratio')).to be true
expect(subject).to be_writable('done_ratio')
end
end

context 'estimated time' do
it 'is writable when the work package is a parent' do
allow(work_package).to receive(:leaf?).and_return(false)
expect(subject.writable?('estimated_hours')).to be true
expect(subject).to be_writable(:estimated_hours)
end

it 'is writable when the work package is a leaf' do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject.writable?('estimated_hours')).to be true
expect(subject).to be_writable(:estimated_hours)
end
end

context 'derived estimated time' do
it 'is not writable when the work package is a parent' do
allow(work_package).to receive(:leaf?).and_return(false)
expect(subject.writable?('derived_estimated_time')).to be false
expect(subject).not_to be_writable(:derived_estimated_time)
end

it 'is not writable when the work package is a leaf' do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject.writable?('derived_estimated_time')).to be false
expect(subject).not_to be_writable(:derived_estimated_time)
end
end

Expand All @@ -229,7 +229,7 @@

context 'scheduled automatically' do
it 'is not writable' do
expect(subject.writable?('start_date')).to be false
expect(subject).not_to be_writable(:start_date)
end
end

Expand All @@ -239,15 +239,15 @@
end

it 'is writable' do
expect(subject.writable?('start_date')).to be true
expect(subject).to be_writable(:start_date)
end
end
end

context 'work package is a leaf' do
it 'is writable' do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject.writable?('start_date')).to be true
expect(subject).to be_writable(:start_date)
end
end
end
Expand All @@ -262,7 +262,7 @@

context 'scheduled automatically' do
it 'is not writable' do
expect(subject.writable?('due_date')).to be false
expect(subject).not_to be_writable(:due_date)
end
end

Expand All @@ -272,15 +272,15 @@
end

it 'is writable' do
expect(subject.writable?('due_date')).to be true
expect(subject).to be_writable(:due_date)
end
end
end

context 'work package is a leaf' do
it 'is writable' do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject.writable?('due_date')).to be true
expect(subject).to be_writable(:due_date)
end
end
end
Expand All @@ -294,24 +294,24 @@

it 'is not writable when the work package is a parent' do
allow(work_package).to receive(:leaf?).and_return(false)
expect(subject.writable?('date')).to be false
expect(subject).not_to be_writable(:date)
end

it 'is writable when the work package is a leaf' do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject.writable?('date')).to be true
expect(subject).to be_writable(:date)
end
end

context 'priority' do
it 'is writable when the work package is a parent' do
allow(work_package).to receive(:leaf?).and_return(false)
expect(subject.writable?('priority')).to be true
expect(subject).to be_writable(:priority)
end

it 'is writable when the work package is a leaf' do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject.writable?('priority')).to be true
expect(subject).to be_writable(:priority)
end
end
end
Expand Down
Expand Up @@ -64,19 +64,19 @@

describe '#writable?' do
it 'percentage done is writable' do
expect(subject.writable?(:done_ratio)).to be true
expect(subject).to be_writable(:done_ratio)
end

it 'estimated time is writable' do
expect(subject.writable?(:estimated_hours)).to be true
expect(subject).to be_writable(:estimated_hours)
end

it 'start date is writable' do
expect(subject.writable?(:start_date)).to be true
expect(subject).to be_writable(:start_date)
end

it 'finish date is writable' do
expect(subject.writable?(:due_date)).to be true
expect(subject).to be_writable(:due_date)
end
end

Expand All @@ -98,7 +98,7 @@
end

it 'has a writable date' do
expect(subject.writable?(:date)).to be true
expect(subject).to be_writable(:date)
end
end

Expand Down

0 comments on commit dd46754

Please sign in to comment.