mirror of
https://github.com/discourse/discourse.git
synced 2025-02-12 14:57:30 +08:00
fix tests and allow SE onebox to onebox Meta cause I need that for an post I am writing
This commit is contained in:
parent
74041be23b
commit
54d8c963d0
|
@ -12,7 +12,7 @@ module Oneboxer
|
||||||
|
|
||||||
# http://rubular.com/r/V3T0I1VTPn
|
# http://rubular.com/r/V3T0I1VTPn
|
||||||
REGEX =
|
REGEX =
|
||||||
/^http:\/\/(?:(?<subdomain>\w*)\.)?(?<domain>#{DOMAINS.join('|')})\.com\/(?:questions|q)\/(?<question>\d*)/
|
/^http:\/\/(?:(?:(?<subsubdomain>\w*)\.)?(?<subdomain>\w*)\.)?(?<domain>#{DOMAINS.join('|')})\.com\/(?:questions|q)\/(?<question>\d*)/
|
||||||
|
|
||||||
matcher REGEX
|
matcher REGEX
|
||||||
favicon 'stackexchange.png'
|
favicon 'stackexchange.png'
|
||||||
|
@ -20,9 +20,9 @@ module Oneboxer
|
||||||
def translate_url
|
def translate_url
|
||||||
@url.match(REGEX) do |match|
|
@url.match(REGEX) do |match|
|
||||||
site = if match[:domain] == 'stackexchange'
|
site = if match[:domain] == 'stackexchange'
|
||||||
match[:subdomain]
|
[match[:subsubdomain],match[:subdomain]].compact.join('.')
|
||||||
else
|
else
|
||||||
match[:domain]
|
[match[:subdomain],match[:domain]].compact.join('.')
|
||||||
end
|
end
|
||||||
|
|
||||||
["http://api.stackexchange.com/2.1/",
|
["http://api.stackexchange.com/2.1/",
|
||||||
|
|
|
@ -36,6 +36,27 @@ describe Oneboxer::StackExchangeOnebox do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the question is from Meta Stack Overflow' do
|
||||||
|
let(:site) { 'meta.stackoverflow' }
|
||||||
|
|
||||||
|
it 'returns the correct api url' do
|
||||||
|
onebox = described_class.new("http://meta.stackoverflow.com/q/#{question}")
|
||||||
|
|
||||||
|
expect(onebox.translate_url).to eq api_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the question is from a Meta Stack Exchange subdomain' do
|
||||||
|
let(:site) { 'meta.gamedev' }
|
||||||
|
|
||||||
|
it 'returns the correct api url' do
|
||||||
|
onebox = described_class.new("http://meta.gamedev.stackexchange.com/q/#{question}")
|
||||||
|
|
||||||
|
expect(onebox.translate_url).to eq api_url
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
context 'when the question is from a Stack Exchange subdomain' do
|
context 'when the question is from a Stack Exchange subdomain' do
|
||||||
let(:site) { 'gamedev' }
|
let(:site) { 'gamedev' }
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe UserActionsController do
|
||||||
action = actions[0]
|
action = actions[0]
|
||||||
action["acting_name"].should == post.user.name
|
action["acting_name"].should == post.user.name
|
||||||
action["email"].should be_nil
|
action["email"].should be_nil
|
||||||
action["post_number"].should == "1"
|
action["post_number"].should == 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user