mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
controllers with rspec3 syntax
This commit is contained in:
@ -3,7 +3,7 @@ require "spec_helper"
|
||||
describe Admin::BackupsController do
|
||||
|
||||
it "is a subclass of AdminController" do
|
||||
(Admin::BackupsController < Admin::AdminController).should == true
|
||||
expect(Admin::BackupsController < Admin::AdminController).to eq(true)
|
||||
end
|
||||
|
||||
let(:backup_filename) { "2014-02-10-065935.tar.gz" }
|
||||
@ -28,7 +28,7 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :get, :index, format: :html
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
end
|
||||
@ -40,11 +40,11 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :get, :index, format: :json
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json[0]["filename"].should == "backup1"
|
||||
json[1]["filename"].should == "backup2"
|
||||
expect(json[0]["filename"]).to eq("backup1")
|
||||
expect(json[1]["filename"]).to eq("backup2")
|
||||
end
|
||||
|
||||
end
|
||||
@ -58,7 +58,7 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :get, :status
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
end
|
||||
@ -70,7 +70,7 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :post, :create, { with_uploads: false }
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
end
|
||||
@ -82,7 +82,7 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :delete, :cancel
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
end
|
||||
@ -99,8 +99,8 @@ describe Admin::BackupsController do
|
||||
|
||||
get :show, id: backup_filename
|
||||
|
||||
response.headers['Content-Length'].should == 5
|
||||
response.headers['Content-Disposition'].should =~ /attachment; filename/
|
||||
expect(response.headers['Content-Length']).to eq(5)
|
||||
expect(response.headers['Content-Disposition']).to match(/attachment; filename/)
|
||||
end
|
||||
|
||||
it "returns 404 when the backup does not exist" do
|
||||
@ -108,7 +108,7 @@ describe Admin::BackupsController do
|
||||
|
||||
get :show, id: backup_filename
|
||||
|
||||
response.should be_not_found
|
||||
expect(response).to be_not_found
|
||||
end
|
||||
|
||||
end
|
||||
@ -121,14 +121,14 @@ describe Admin::BackupsController do
|
||||
Backup.expects(:[]).with(backup_filename).returns(b)
|
||||
b.expects(:remove)
|
||||
xhr :delete, :destroy, id: backup_filename
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "doesn't remove the backup if not found" do
|
||||
Backup.expects(:[]).with(backup_filename).returns(nil)
|
||||
b.expects(:remove).never
|
||||
xhr :delete, :destroy, id: backup_filename
|
||||
response.should_not be_success
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
end
|
||||
@ -144,7 +144,7 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :get, :logs, format: :html
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
@ -155,7 +155,7 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :post, :restore, id: backup_filename
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
end
|
||||
@ -167,7 +167,7 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :get, :rollback
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
end
|
||||
@ -179,7 +179,7 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :put, :readonly, enable: true
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "disables readonly mode" do
|
||||
@ -187,7 +187,7 @@ describe Admin::BackupsController do
|
||||
|
||||
xhr :put, :readonly, enable: false
|
||||
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user