Skip to content

Commit

Permalink
fix: GraphQL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentinchampenois committed Dec 18, 2023
1 parent fc55da5 commit 5ca0512
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 50 deletions.
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 2 additions & 49 deletions spec/types/deployement_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,25 @@
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
end

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

0 comments on commit 5ca0512

Please sign in to comment.