Skip to content

Commit

Permalink
Patch up some more spots with repository search
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonperl committed May 27, 2021
1 parent bfd0de5 commit 3798667
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 67 deletions.
6 changes: 1 addition & 5 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@
<% unless on_homepage? && !logged_in? %>
<ul class="nav navbar-nav navbar-left">
<li class=' <%= 'hidden-xs' if on_search_page %>'>
<% if current_host.present? || request.original_fullpath =~ /^\/repos/i %>
<%= render 'repositories/search_form' %>
<% else %>
<%= render 'projects/search_form' %>
<% end %>
<%= render 'projects/search_form' %>
</li>
</ul>
<% end %>
Expand Down
26 changes: 0 additions & 26 deletions app/views/repositories/_search_form.html.erb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/repositories/languages.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<h4>
<div class="pictogram pictogram-<%= language['key'].downcase %>"></div>
<div class="blurb">
<%= link_to language['key'], github_search_path(language: language['key']) %>
<%= link_to language['key'], search_path(language: language['key']) %>
<small><%= number_to_human language['doc_count'] %> Repos</small>
</div>
</h4>
Expand Down
20 changes: 6 additions & 14 deletions spec/requests/api/repositories_spec.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
# frozen_string_literal: true

require "rails_helper"

describe "Api::RepositoriesController" do
let!(:repository) { create(:repository) }

describe "GET /api/github/search", type: :request do
it "renders successfully" do
get '/api/github/search'
expect(response).to have_http_status(:success)
expect(response.content_type).to eq('application/json')
expect(json).to eq []
end
end

describe "GET /api/github/:owner/:name/dependencies", type: :request do
it "renders successfully" do
get "/api/github/#{repository.full_name}/dependencies"
expect(response).to have_http_status(:success)
expect(response.content_type).to eq('application/json')
expect(json.to_json).to be_json_eql repository.as_json({except: [:id, :repository_organisation_id, :repository_user_id], methods: [:github_contributions_count, :github_id]}).merge(dependencies: []).to_json
expect(response.content_type).to eq("application/json")
expect(json.to_json).to be_json_eql repository.as_json({ except: %i[id repository_organisation_id repository_user_id], methods: %i[github_contributions_count github_id] }).merge(dependencies: []).to_json
end
end

describe "GET /api/github/:owner/:name/projects", type: :request do
it "renders successfully" do
get "/api/github/#{repository.full_name}/projects"
expect(response).to have_http_status(:success)
expect(response.content_type).to eq('application/json')
expect(response.content_type).to eq("application/json")
expect(json).to eq []
end
end
Expand All @@ -35,8 +27,8 @@
it "renders successfully" do
get "/api/github/#{repository.full_name}"
expect(response).to have_http_status(:success)
expect(response.content_type).to eq('application/json')
expect(json.to_json).to be_json_eql repository.to_json({except: [:id, :repository_organisation_id, :repository_user_id], methods: [:github_contributions_count, :github_id]})
expect(response.content_type).to eq("application/json")
expect(json.to_json).to be_json_eql repository.to_json({ except: %i[id repository_organisation_id repository_user_id], methods: %i[github_contributions_count github_id] })
end
end
end
27 changes: 6 additions & 21 deletions spec/requests/repositories_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "rails_helper"

describe "RepositoriesController" do
Expand All @@ -8,45 +9,29 @@

describe "GET /github", type: :request do
it "renders successfully when logged out" do
visit hosts_path(host_type: 'github')
expect(page).to have_content 'Repositories'
end
end

describe "GET /github/search", type: :request, elasticsearch: true do
it "renders successfully when logged out" do
Repository.__elasticsearch__.refresh_index!
visit github_search_path
expect(page).to have_content repository.full_name
end
end

describe "GET /github/search.atom", type: :request, elasticsearch: true do
it "renders successfully when logged out" do
Repository.__elasticsearch__.refresh_index!
visit github_search_path(format: :atom)
expect(page).to have_content repository.full_name
visit hosts_path(host_type: "github")
expect(page).to have_content "Repositories"
end
end

describe "GET /github/languages", type: :request do
it "renders successfully when logged out" do
visit github_languages_path
expect(page).to have_content 'Languages'
expect(page).to have_content "Languages"
end
end

describe "GET /github/trending", type: :request do
it "renders successfully when logged out" do
visit trending_path
expect(page).to have_content 'Trending'
expect(page).to have_content "Trending"
end
end

describe "GET /github/new", type: :request do
it "renders successfully when logged out" do
visit new_repos_path
expect(page).to have_content 'New'
expect(page).to have_content "New"
end
end

Expand Down

0 comments on commit 3798667

Please sign in to comment.