Skip to content

Commit

Permalink
expect factory to return persisted project query clean after reducing…
Browse files Browse the repository at this point in the history
… to valid subset
  • Loading branch information
toy committed May 7, 2024
1 parent 5fb2ce0 commit b94ccb2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/queries/projects/factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def find_persisted_query_and_set_attributes(id, params, user, duplicate:)
return unless query

query.valid_subset!
query.clear_changes_information

query = duplicate_query(query) if duplicate

Expand Down
20 changes: 20 additions & 0 deletions spec/models/queries/projects/factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,26 @@
expect(find.selects.map(&:attribute))
.to eq(%i[project_status name])
end

it { is_expected.not_to be_changed }

context "when params are changing an attribute" do
let(:params) { { selects: %w[description project_status] } }

it { is_expected.to be_changed }
end

context "when params are changing an attribute to invalid value" do
let(:params) { { selects: %w[project_status name blubs] } }

it { is_expected.to be_changed }
end

context "when params are changing an attribute to valid subset" do
let(:params) { { selects: %w[project_status name] } }

it { is_expected.not_to be_changed }
end
end
end

Expand Down

0 comments on commit b94ccb2

Please sign in to comment.