Add tests
This commit is contained in:
parent
2a5a0bebb3
commit
f96fffeb34
|
@ -35,6 +35,11 @@ describe TopicView do
|
||||||
tv = TopicView.new(topic.id, coding_horror, slow_platform: true)
|
tv = TopicView.new(topic.id, coding_horror, slow_platform: true)
|
||||||
expect(tv.chunk_size).to eq(TopicView.slow_chunk_size)
|
expect(tv.chunk_size).to eq(TopicView.slow_chunk_size)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns `print_chunk_size` when print param is true" do
|
||||||
|
tv = TopicView.new(topic.id, coding_horror, print: true)
|
||||||
|
expect(tv.chunk_size).to eq(TopicView.print_chunk_size)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with a few sample posts" do
|
context "with a few sample posts" do
|
||||||
|
|
|
@ -84,6 +84,28 @@ describe TopicsController do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "print" do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
context "when the SiteSetting is enabled" do
|
||||||
|
before do
|
||||||
|
SiteSetting.stubs(:max_prints_per_hour_per_user).returns(10)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "uses the application layout when there's no param" do
|
||||||
|
get :show, topic_id: topic.id, slug: topic.slug
|
||||||
|
expect(response).to render_template(layout: 'application')
|
||||||
|
assert_select "meta[name=fragment]", true, "it has the meta tag"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "uses the crawler layout when there's an print param" do
|
||||||
|
get :show, topic_id: topic.id, slug: topic.slug, print: 'true'
|
||||||
|
expect(response).to render_template(layout: 'crawler')
|
||||||
|
assert_select "meta[name=fragment]", false, "it doesn't have the meta tag"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'clear_notifications' do
|
describe 'clear_notifications' do
|
||||||
it 'correctly clears notifications if specified via cookie' do
|
it 'correctly clears notifications if specified via cookie' do
|
||||||
notification = Fabricate(:notification)
|
notification = Fabricate(:notification)
|
||||||
|
|
|
@ -747,6 +747,22 @@ describe TopicsController do
|
||||||
expect(IncomingLink.count).to eq(1)
|
expect(IncomingLink.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't renders the print view by default" do
|
||||||
|
user = Fabricate(:user)
|
||||||
|
get :show, topic_id: topic.id, slug: topic.slug, print: true
|
||||||
|
|
||||||
|
expect(response).to be_forbidden
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'renders the print view when enabled' do
|
||||||
|
SiteSetting.max_prints_per_hour_per_user = 10
|
||||||
|
|
||||||
|
user = Fabricate(:user)
|
||||||
|
get :show, topic_id: topic.id, slug: topic.slug, print: true
|
||||||
|
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
|
||||||
it 'records redirects' do
|
it 'records redirects' do
|
||||||
@request.env['HTTP_REFERER'] = 'http://twitter.com'
|
@request.env['HTTP_REFERER'] = 'http://twitter.com'
|
||||||
get :show, { id: topic.id }
|
get :show, { id: topic.id }
|
||||||
|
|
Loading…
Reference in New Issue