Skip to content

Commit

Permalink
Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
dombesz committed Feb 18, 2025
1 parent e8f5978 commit 88f96cb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions spec/models/custom_field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,25 @@
end

context "for a version custom field" do
let(:versions) { [build_stubbed(:version), build_stubbed(:version)] }
let(:versions) { [build_stubbed(:version, project:), build_stubbed(:version, project:)] }
let(:shared_versions_scope) { instance_double(ActiveRecord::Relation) }

before do
field.field_format = "version"
allow(shared_versions_scope)
.to receive(:includes)
.with(:project)
.and_return(versions)
end

context "with a project provided" do
it "returns the project's shared_versions" do
allow(project)
.to receive(:shared_versions)
.and_return(versions)
.and_return(shared_versions_scope)

expect(field.possible_values_options(project))
.to eql(versions.sort.map { |u| [u.name, u.id.to_s] })
.to eql(versions.sort.map { |u| [u.name, u.id.to_s, project.name] })
end
end

Expand All @@ -312,21 +317,21 @@
it "returns the project's shared_versions" do
allow(project)
.to receive(:shared_versions)
.and_return(versions)
.and_return(shared_versions_scope)

expect(field.possible_values_options(project))
.to eql(versions.sort.map { |u| [u.name, u.id.to_s] })
.to eql(versions.sort.map { |u| [u.name, u.id.to_s, project.name] })
end
end

context "with nothing provided" do
it "returns the systemwide versions" do
allow(Version)
.to receive(:systemwide)
.and_return(versions)
.and_return(shared_versions_scope)

expect(field.possible_values_options)
.to eql(versions.sort.map { |u| [u.name, u.id.to_s] })
.to eql(versions.sort.map { |u| [u.name, u.id.to_s, project.name] })
end
end
end
Expand Down

0 comments on commit 88f96cb

Please sign in to comment.