Remove code related to /live_articles (#7822)

This commit is contained in:
Anna Buianova 2020-05-13 16:26:13 +03:00 committed by GitHub
parent 792721d7bc
commit 82799eb752
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 62 deletions

View file

@ -45,7 +45,6 @@ class Internal::ArticlesController < Internal::ApplicationController
article.user_id = article_params[:user_id].to_i
article.update!(article_params)
Article.where.not(id: article.id).where(live_now: true).update_all(live_now: false) if article.live_now
CacheBuster.bust("/live_articles")
render body: nil
end

View file

@ -28,7 +28,6 @@ module Internal
@event = Event.find(params[:id])
@events = Event.order("starts_at DESC")
if @event.update(event_params)
CacheBuster.bust("/live_articles")
flash[:success] = "#{@event.title} was successfully updated"
redirect_to "/internal/events"
else

View file

@ -1,37 +0,0 @@
class LiveArticlesController < ApplicationController
# No authorization required for entirely public controller
before_action :set_cache_control_headers, only: [:index]
def index
@event = Event.find_by(live_now: true)
@article = Article.where(live_now: true).order("featured_number DESC").first
if @event
set_surrogate_key_header "live--event_#{@event.id}"
render json:
{
title: @event.title,
path: @event.location_url,
tag_list: [],
user: {
name: @event.host_name,
profile_pic: ProfileImage.new(@event).get(width: 50)
}
}
elsif @article
set_surrogate_key_header "live--article_#{@article.id}"
render json:
{
title: @article.title,
path: @article.path,
tag_list: @article.tag_list,
user: {
name: @article.user.name,
profile_pic: ProfileImage.new(@article.user).get(width: 50)
}
}
else
set_surrogate_key_header "live--nothing"
render json: {}
end
end
end

View file

@ -194,7 +194,6 @@ Rails.application.routes.draw do
end
end
resources :stripe_active_cards, only: %i[create update destroy]
resources :live_articles, only: [:index]
resources :github_repos, only: %i[index] do
collection do
post "/update_or_create", to: "github_repos#update_or_create"

View file

@ -1,22 +0,0 @@
require "rails_helper"
RSpec.describe "Live Articles", type: :request do
describe "GET /live_articles" do
it "returns no articles if none are live" do
get "/live_articles"
expect(response.body).to eq("{}")
end
it "returns a live article if it is live" do
article = create(:article, live_now: true)
get "/live_articles"
expect(response.body).to include(article.title)
end
it "returns a live event if it is live" do
event = create(:event, live_now: true)
get "/live_articles"
expect(response.body).to include(event.title)
end
end
end