mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
First stab at new user education - configurable messages that pop up on a user's first
few posts/topics.
This commit is contained in:
parent
898efeaea2
commit
b9457197c0
15 changed files with 879 additions and 688 deletions
46
spec/controllers/education_controller_spec.rb
Normal file
46
spec/controllers/education_controller_spec.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe EducationController do
|
||||
|
||||
it "requires you to be logged in" do
|
||||
lambda { xhr :get, :show, id: 'topic' }.should raise_error(Discourse::NotLoggedIn)
|
||||
end
|
||||
|
||||
context 'when logged in' do
|
||||
|
||||
let!(:user) { log_in(:user) }
|
||||
|
||||
it "returns 404 from a missing id" do
|
||||
xhr :get, :show, id: 'made-up'
|
||||
response.response_code.should == 404
|
||||
end
|
||||
|
||||
it 'raises an error with a weird id' do
|
||||
xhr :get, :show, id: '../some-path'
|
||||
response.should_not be_success
|
||||
end
|
||||
|
||||
context 'with a valid id' do
|
||||
|
||||
let(:markdown_content) { "Education *markdown* content" }
|
||||
let(:html_content) {"HTML Content"}
|
||||
|
||||
before do
|
||||
MultisiteI18n.expects(:t).with("education.new-topic", anything).returns(markdown_content)
|
||||
PrettyText.expects(:cook).with(markdown_content).returns(html_content)
|
||||
xhr :get, :show, id: 'new-topic'
|
||||
end
|
||||
|
||||
it "succeeds" do
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it "converts markdown into HTML" do
|
||||
response.body.should == html_content
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue