Skip to content

Further default orders for the API#7436

Merged
mrcasals merged 5 commits intodecidim:developfrom
mainio:fix/api-default-order-for-components
Feb 23, 2021
Merged

Further default orders for the API#7436
mrcasals merged 5 commits intodecidim:developfrom
mainio:fix/api-default-order-for-components

Conversation

@ahukkanen
Copy link
Copy Markdown
Contributor

@ahukkanen ahukkanen commented Feb 22, 2021

🎩 What? Why?

  • Move the API default order adding implemented in Add default order by ID to API list queries #7424 to its own module
  • Apply the default order also for the Decidim::Core::ComponentList class
  • Apply the default order also for the Decidim::Core::ParticipatorySpaceListBase class
  • Update the related tests to expect the correct order

This also removes redundant tests from decidim-participatory_processes/spec/lib/query_extensions_spec.rb :

  • describe "participatoryProcesses" do
    • describe "participatoryProcesses" do
      let!(:process1) { create(:participatory_process, organization: current_organization) }
      let!(:process2) { create(:participatory_process, organization: current_organization) }
      let!(:process3) { create(:participatory_process) }
      let(:query) { %({ participatoryProcesses { id }}) }
      it "returns all the processes" do
      expect(response["participatoryProcesses"]).to include("id" => process1.id.to_s)
      expect(response["participatoryProcesses"]).to include("id" => process2.id.to_s)
      expect(response["participatoryProcesses"]).not_to include("id" => process3.id.to_s)
      end
      end
    • describe "participatoryProcesses" do
      let!(:process1) { create(:participatory_process, organization: current_organization) }
      let!(:process2) { create(:participatory_process, organization: current_organization) }
      let!(:process3) { create(:participatory_process) }
      let(:query) { %({ participatoryProcesses { id }}) }
      it "returns all the processes" do
      expect(response["participatoryProcesses"]).to include("id" => process1.id.to_s)
      expect(response["participatoryProcesses"]).to include("id" => process2.id.to_s)
      expect(response["participatoryProcesses"]).not_to include("id" => process3.id.to_s)
      end
      end
  • describe "participatoryProcess" do
    • describe "participatoryProcess" do
      let(:query) { %({ participatoryProcess(id: \"#{id}\") { id }}) }
      context "with a participatory process that belongs to the current organization" do
      let!(:process) { create(:participatory_process, organization: current_organization) }
      let(:id) { process.id }
      it "returns the process" do
      expect(response["participatoryProcess"]).to eq("id" => process.id.to_s)
      end
      end
      context "with a participatory process of another organization" do
      let!(:process) { create(:participatory_process) }
      let(:id) { process.id }
      it "returns nil" do
      expect(response["participatoryProcess"]).to be_nil
      end
      end
      end
    • describe "participatoryProcess" do
      let(:query) { %({ participatoryProcess(id: \"#{id}\") { id }}) }
      context "with a participatory process that belongs to the current organization" do
      let!(:process) { create(:participatory_process, organization: current_organization) }
      let(:id) { process.id }
      it "returns the process" do
      expect(response["participatoryProcess"]).to eq("id" => process.id.to_s)
      end
      end
      context "with a participatory process of another organization" do
      let!(:process) { create(:participatory_process) }
      let(:id) { process.id }
      it "returns nil" do
      expect(response["participatoryProcess"]).to be_nil
      end
      end
      end

We don't need the same test twice.

📌 Related Issues

Testing

See #7424.

📋 Checklist

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

Copy link
Copy Markdown
Contributor

@mrcasals mrcasals left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thanks!

@mrcasals mrcasals merged commit d40e4ab into decidim:develop Feb 23, 2021
@ahukkanen ahukkanen deleted the fix/api-default-order-for-components branch February 23, 2021 08:57
entantoencuanto added a commit that referenced this pull request Feb 25, 2021
* develop: (232 commits)
  Add Votings to Open Data export (#7388)
  Add order in not highlighted assemblies by weight (#7444)
  Resort Menus (#7460)
  Polling Officer Zone (#7439)
  Fix session timeout when using multiple windows or tabs (#7459)
  Fix display of debates with multiple dates (#7393)
  chore: split election tests (#7451)
  style: make selected values primary labels with delete button (#7448)
  Fix and tests to avoid registered users being invited again (#7392)
  Migrate Admin menus to Menu Registry (#7368)
  New Crowdin updates (#7338)
  Bump to carrierwave 2.2.0 (#7441)
  Voting: show callout when Polling Stations miss Polling Officers (#7417)
  Further default orders for the API (#7436)
  Fix random order inconsistencies (#7437)
  Ensure Rails is locked to 5.2.4.x series (#7430)
  Add default order by ID to API list queries (#7424)
  Update dependencies (#7422)
  Ignore warning on CI when no artifacts to upload (#7420)
  Filter and search polling officers (#7411)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants