mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 14:42:46 +08:00
REFACTOR: about & badge controllers => requests
This commit is contained in:
parent
209a8d5e31
commit
450a600721
|
@ -6,22 +6,22 @@ describe AboutController do
|
|||
|
||||
it "should display the about page for anonymous user when login_required is false" do
|
||||
SiteSetting.login_required = false
|
||||
get :index
|
||||
get "/about"
|
||||
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it 'should redirect to login page for anonymous user when login_required is true' do
|
||||
SiteSetting.login_required = true
|
||||
get :index
|
||||
get "/about"
|
||||
|
||||
expect(response).to redirect_to '/login'
|
||||
end
|
||||
|
||||
it "should display the about page for logged in user when login_required is true" do
|
||||
SiteSetting.login_required = true
|
||||
log_in
|
||||
get :index
|
||||
sign_in(Fabricate(:user))
|
||||
get "/about"
|
||||
|
||||
expect(response).to be_success
|
||||
end
|
|
@ -10,7 +10,7 @@ describe BadgesController do
|
|||
|
||||
context 'index' do
|
||||
it 'should return a list of all badges' do
|
||||
get :index, format: :json
|
||||
get "/badges.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
|
@ -20,22 +20,22 @@ describe BadgesController do
|
|||
|
||||
context 'show' do
|
||||
it "should return a badge" do
|
||||
get :show, params: { id: badge.id }, format: :json
|
||||
get "/badges/#{badge.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
expect(parsed["badge"]).to be_present
|
||||
end
|
||||
|
||||
it "should mark the notification as viewed" do
|
||||
log_in_user(user)
|
||||
sign_in(user)
|
||||
user_badge = BadgeGranter.grant(badge, user)
|
||||
expect(user_badge.notification.read).to eq(false)
|
||||
get :show, params: { id: badge.id }
|
||||
get "/badges/#{badge.id}.json"
|
||||
expect(user_badge.notification.reload.read).to eq(true)
|
||||
end
|
||||
|
||||
it 'renders rss feed of a badge' do
|
||||
get :show, params: { id: badge.id }, format: :rss
|
||||
get "/badges/#{badge.id}.rss"
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.content_type).to eq('application/rss+xml')
|
||||
end
|
Loading…
Reference in New Issue
Block a user