mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
add spec for raw_email action
This commit is contained in:
parent
72873b8368
commit
f8237e2ac0
1 changed files with 30 additions and 0 deletions
|
@ -68,6 +68,36 @@ describe PostsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'raw_email' do
|
||||
include_examples "action requires login", :get, :raw_email, id: 2
|
||||
|
||||
describe "when logged in" do
|
||||
let(:user) {log_in}
|
||||
let(:post) {Fabricate(:post, user: user, raw_email: 'email_content')}
|
||||
|
||||
it "raises an error if the user doesn't have permission to view raw email" do
|
||||
Guardian.any_instance.expects(:can_view_raw_email?).returns(false)
|
||||
|
||||
xhr :get, :raw_email, id: post.id
|
||||
|
||||
response.should be_forbidden
|
||||
end
|
||||
|
||||
it "can view raw email" do
|
||||
Guardian.any_instance.expects(:can_view_raw_email?).returns(true)
|
||||
|
||||
xhr :get, :raw_email, id: post.id
|
||||
|
||||
response.should be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
json.should be_present
|
||||
json['raw_email'].should == 'email_content'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'show' do
|
||||
include_examples 'finding and showing post' do
|
||||
let(:action) { :show }
|
||||
|
|
Loading…
Reference in a new issue