Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use be_writable instead of writable? in specs

Dombi Attilaf72699403d76
diff --git a/modules/backlogs/spec/api/work_packages/schema/specific_work_package_schema_spec.rb b/modules/backlogs/spec/api/work_packages/schema/specific_work_package_schema_spec.rb
index f72f040147b..8dfd6d4a0d4 100644
--- a/modules/backlogs/spec/api/work_packages/schema/specific_work_package_schema_spec.rb
+++ b/modules/backlogs/spec/api/work_packages/schema/specific_work_package_schema_spec.rb
@@ -53,7 +53,11 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
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
@@ -66,7 +70,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
it "is writable" do
- expect(subject.writable?(:version)).to be(true)
+ expect(subject).to be_writable(:version)
end
end
@@ -83,7 +87,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
it 'is writable' do
- expect(subject.writable?(:remaining_hours)).to be(true)
+ expect(subject).to be_writable(:remaining_hours)
end
end
@@ -93,7 +97,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
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
diff --git a/modules/dashboards/spec/lib/dashboards/grid_registration_spec.rb b/modules/dashboards/spec/lib/dashboards/grid_registration_spec.rb
index abf309bfb8b..016c02c0550 100644
--- a/modules/dashboards/spec/lib/dashboards/grid_registration_spec.rb
+++ b/modules/dashboards/spec/lib/dashboards/grid_registration_spec.rb
@@ -66,8 +66,8 @@ describe Dashboards::GridRegistration do
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
@@ -75,8 +75,8 @@ describe Dashboards::GridRegistration 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
diff --git a/spec/constants/settings/definition_spec.rb b/spec/constants/settings/definition_spec.rb
index f7facd7012d..06e1dc99235 100644
--- a/spec/constants/settings/definition_spec.rb
+++ b/spec/constants/settings/definition_spec.rb
@@ -909,8 +909,8 @@ describe Settings::Definition do
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
diff --git a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb
index c4c69bfffda..05b5b97e4e0 100644
--- a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb
@@ -176,46 +176,46 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
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
@@ -229,7 +229,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
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
@@ -239,7 +239,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
it 'is writable' do
- expect(subject.writable?('start_date')).to be true
+ expect(subject).to be_writable(:start_date)
end
end
end
@@ -247,7 +247,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
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
@@ -262,7 +262,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
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
@@ -272,7 +272,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
it 'is writable' do
- expect(subject.writable?('due_date')).to be true
+ expect(subject).to be_writable(:due_date)
end
end
end
@@ -280,7 +280,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
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
@@ -294,24 +294,24 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema 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?('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
diff --git a/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb b/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb
index 1d48815ede8..5c1a94f59b5 100644
--- a/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb
@@ -64,19 +64,19 @@ describe ::API::V3::WorkPackages::Schema::TypedWorkPackageSchema do
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
@@ -98,7 +98,7 @@ describe ::API::V3::WorkPackages::Schema::TypedWorkPackageSchema do
end
it 'has a writable date' do
- expect(subject.writable?(:date)).to be true
+ expect(subject).to be_writable(:date)
end
end