Add frozen string literal comment to files.
This commit is contained in:
parent
44e832813c
commit
75046f1d92
2
Gemfile
2
Gemfile
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'translations-manager', git: 'https://github.com/discourse/translations-manager.git'
|
gem 'translations-manager', git: 'https://github.com/discourse/translations-manager.git'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module TopicAnswerMixin
|
module TopicAnswerMixin
|
||||||
def self.included(klass)
|
def self.included(klass)
|
||||||
klass.attributes :has_accepted_answer, :can_have_answer
|
klass.attributes :has_accepted_answer, :can_have_answer
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'translations_manager'
|
require 'translations_manager'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# name: discourse-solved
|
# name: discourse-solved
|
||||||
# about: Add a solved button to answers on Discourse
|
# about: Add a solved button to answers on Discourse
|
||||||
# version: 0.1
|
# version: 0.1
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe "Managing Posts solved status" do
|
RSpec.describe "Managing Posts solved status" do
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
require_dependency 'site'
|
require_dependency 'site'
|
||||||
|
|
||||||
|
|
|
@ -1,50 +1,52 @@
|
||||||
require 'rails_helper'
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RSpec.describe TopicsController do
|
require 'rails_helper'
|
||||||
let(:p1) { Fabricate(:post, like_count: 1) }
|
|
||||||
let(:topic) { p1.topic }
|
RSpec.describe TopicsController do
|
||||||
let(:p2) { Fabricate(:post, like_count: 2, topic: topic, user: Fabricate(:user)) }
|
let(:p1) { Fabricate(:post, like_count: 1) }
|
||||||
|
let(:topic) { p1.topic }
|
||||||
def schema_json(answerCount)
|
let(:p2) { Fabricate(:post, like_count: 2, topic: topic, user: Fabricate(:user)) }
|
||||||
if answerCount > 0
|
|
||||||
answer_json = ',"acceptedAnswer":{"@type":"Answer","text":"%{answer_text}","upvoteCount":%{answer_likes},"dateCreated":"%{answered_at}","url":"%{answer_url}","author":{"@type":"Person","name":"%{username2}"}}' % {
|
def schema_json(answerCount)
|
||||||
answer_text: p2.excerpt,
|
if answerCount > 0
|
||||||
answer_likes: p2.like_count,
|
answer_json = ',"acceptedAnswer":{"@type":"Answer","text":"%{answer_text}","upvoteCount":%{answer_likes},"dateCreated":"%{answered_at}","url":"%{answer_url}","author":{"@type":"Person","name":"%{username2}"}}' % {
|
||||||
answered_at: p2.created_at.as_json,
|
answer_text: p2.excerpt,
|
||||||
answer_url: p2.full_url,
|
answer_likes: p2.like_count,
|
||||||
username2: p2.user&.username
|
answered_at: p2.created_at.as_json,
|
||||||
}
|
answer_url: p2.full_url,
|
||||||
else
|
username2: p2.user&.username
|
||||||
answer_json = ""
|
}
|
||||||
end
|
else
|
||||||
|
answer_json = ""
|
||||||
'<script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"%{title}","mainEntity":{"@type":"Question","name":"%{title}","text":"%{question_text}","upvoteCount":%{question_likes},"answerCount":%{answerCount},"dateCreated":"%{created_at}","author":{"@type":"Person","name":"%{username1}"}%{answer_json}}}</script>' % {
|
end
|
||||||
title: topic.title,
|
|
||||||
question_text: p1.excerpt,
|
'<script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"%{title}","mainEntity":{"@type":"Question","name":"%{title}","text":"%{question_text}","upvoteCount":%{question_likes},"answerCount":%{answerCount},"dateCreated":"%{created_at}","author":{"@type":"Person","name":"%{username1}"}%{answer_json}}}</script>' % {
|
||||||
question_likes: p1.like_count,
|
title: topic.title,
|
||||||
answerCount: answerCount,
|
question_text: p1.excerpt,
|
||||||
created_at: topic.created_at.as_json,
|
question_likes: p1.like_count,
|
||||||
username1: topic.user&.name,
|
answerCount: answerCount,
|
||||||
answer_json: answer_json
|
created_at: topic.created_at.as_json,
|
||||||
}
|
username1: topic.user&.name,
|
||||||
end
|
answer_json: answer_json
|
||||||
|
}
|
||||||
before do
|
end
|
||||||
SiteSetting.allow_solved_on_all_topics = true
|
|
||||||
end
|
before do
|
||||||
|
SiteSetting.allow_solved_on_all_topics = true
|
||||||
it 'should include correct schema information in header' do
|
end
|
||||||
get "/t/#{topic.slug}/#{topic.id}"
|
|
||||||
|
it 'should include correct schema information in header' do
|
||||||
expect(response.body).to include(schema_json(0))
|
get "/t/#{topic.slug}/#{topic.id}"
|
||||||
|
|
||||||
p2.custom_fields["is_accepted_answer"] = true
|
expect(response.body).to include(schema_json(0))
|
||||||
p2.save_custom_fields
|
|
||||||
topic.custom_fields["accepted_answer_post_id"] = p2.id
|
p2.custom_fields["is_accepted_answer"] = true
|
||||||
topic.save_custom_fields
|
p2.save_custom_fields
|
||||||
|
topic.custom_fields["accepted_answer_post_id"] = p2.id
|
||||||
get "/t/#{topic.slug}/#{topic.id}"
|
topic.save_custom_fields
|
||||||
|
|
||||||
expect(response.body).to include(schema_json(1))
|
get "/t/#{topic.slug}/#{topic.id}"
|
||||||
end
|
|
||||||
end
|
expect(response.body).to include(schema_json(1))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe TopicAnswerMixin do
|
describe TopicAnswerMixin do
|
||||||
|
|
Loading…
Reference in New Issue