From 5ca051293fe7f88e14351598ef8a0acd87e0d414 Mon Sep 17 00:00:00 2001 From: quentinchampenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Mon, 18 Dec 2023 10:20:09 +0100 Subject: [PATCH] fix: GraphQL tests --- config/application.rb | 2 +- spec/types/deployement_type_spec.rb | 51 ++--------------------------- 2 files changed, 3 insertions(+), 50 deletions(-) diff --git a/config/application.rb b/config/application.rb index 0872b7afb3..ae25d1ded8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -49,7 +49,7 @@ class Application < Rails::Application require "extends/services/decidim/iframe_disabler_extends" Decidim::GraphiQL::Rails.config.tap do |config| - config.initial_query = "{\n deployment {\n version\n branch\n remote\n upToDate\n currentCommit\n latestCommit\n locallyModified\n }\n}".html_safe + config.initial_query = "{\n deployment {\n decidim_version\n }\n}".html_safe end end end diff --git a/spec/types/deployement_type_spec.rb b/spec/types/deployement_type_spec.rb index 471db8b141..152edb033b 100644 --- a/spec/types/deployement_type_spec.rb +++ b/spec/types/deployement_type_spec.rb @@ -6,49 +6,16 @@ describe "DeploymentType" do include_context "with a graphql class type" let(:schema) { Decidim::Api::Schema } - - let(:locale) { "en" } - let(:query) do %( query { deployment { - version - branch - remote - upToDate - currentCommit - latestCommit - locallyModified + decidim_version } } ) end - let(:github_response) do - JSON.dump(sha: "220fd7b6f8701816c60c0610d5a62a59b962b231") - end - - let(:branch) { "master" } - let(:repo_name) { "repo_name" } - - before do - stub_request(:get, "https://api.github.com/repos/repo_name/commits/master").with( - headers: { - "Accept" => "*/*", - "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", - "Host" => "api.github.com", - "User-Agent" => "Ruby" - } - ).to_return(status: 200, body: github_response, headers: {}) - # rubocop:disable RSpec/AnyInstance - allow_any_instance_of(DeploymentType).to receive(:`).with("git ls-remote --get-url").and_return(repo_name) - allow_any_instance_of(DeploymentType).to receive(:`).with("git rev-parse HEAD").and_return("220fd7b6f8701816c60c0610d5a62a59b962b231") - allow_any_instance_of(DeploymentType).to receive(:`).with("git rev-parse --abbrev-ref HEAD").and_return("master") - allow_any_instance_of(DeploymentType).to receive(:`).with("git status --porcelain").and_return("") - # rubocop:enable RSpec/AnyInstance - end - describe "valid query" do it "executes sucessfully" do expect { response }.not_to raise_error @@ -56,22 +23,8 @@ it "has deployment" do expect(response["deployment"]).to eq({ - "version" => Decidim::Core.version, - "branch" => "master", - "remote" => repo_name, - "upToDate" => true, - "currentCommit" => "220fd7b6f8701816c60c0610d5a62a59b962b231", - "latestCommit" => "220fd7b6f8701816c60c0610d5a62a59b962b231", - "locallyModified" => false + "decidim_version" => Decidim.version }) end - - context "when partial_url ends with .git" do - let(:repo_name) { "repo_name.git" } - - it "executes sucessfully" do - expect { response }.not_to raise_error - end - end end end