get oauth_applications_path
assert_response :success
assert_template "oauth2_applications/index"
- assert_select "tr", 2
+ assert_select "tbody tr", 2
end
def test_new
assert_response :success
assert_template "oauth2_applications/new"
assert_select "form", 1 do
- assert_select "input#doorkeeper_application_name", 1
- assert_select "textarea#doorkeeper_application_redirect_uri", 1
- assert_select "input#doorkeeper_application_confidential", 1
+ assert_select "input#oauth2_application_name", 1
+ assert_select "textarea#oauth2_application_redirect_uri", 1
+ assert_select "input#oauth2_application_confidential", 1
Oauth.scopes.each do |scope|
- assert_select "input#doorkeeper_application_scopes_#{scope.name}", 1
+ assert_select "input#oauth2_application_scopes_#{scope.name}", 1
end
end
end
session_for(user)
assert_difference "Doorkeeper::Application.count", 0 do
- post oauth_applications_path(:doorkeeper_application => {
+ post oauth_applications_path(:oauth2_application => {
:name => "Test Application"
})
end
assert_template "oauth2_applications/new"
assert_difference "Doorkeeper::Application.count", 0 do
- post oauth_applications_path(:doorkeeper_application => {
+ post oauth_applications_path(:oauth2_application => {
:name => "Test Application",
:redirect_uri => "https://test.example.com/",
:scopes => ["bad_scope"]
assert_template "oauth2_applications/new"
assert_difference "Doorkeeper::Application.count", 1 do
- post oauth_applications_path(:doorkeeper_application => {
+ post oauth_applications_path(:oauth2_application => {
:name => "Test Application",
:redirect_uri => "https://test.example.com/",
:scopes => ["read_prefs"]
assert_redirected_to oauth_application_path(:id => Doorkeeper::Application.find_by(:name => "Test Application").id)
end
+ def test_create_privileged
+ session_for(create(:user))
+
+ assert_difference "Doorkeeper::Application.count", 0 do
+ post oauth_applications_path(:oauth2_application => {
+ :name => "Test Application",
+ :redirect_uri => "https://test.example.com/",
+ :scopes => ["read_email"]
+ })
+ end
+ assert_response :success
+ assert_template "oauth2_applications/new"
+
+ session_for(create(:administrator_user))
+
+ assert_difference "Doorkeeper::Application.count", 1 do
+ post oauth_applications_path(:oauth2_application => {
+ :name => "Test Application",
+ :redirect_uri => "https://test.example.com/",
+ :scopes => ["read_email"]
+ })
+ end
+ assert_response :redirect
+ assert_redirected_to oauth_application_path(:id => Doorkeeper::Application.find_by(:name => "Test Application").id)
+ end
+
def test_show
user = create(:user)
client = create(:oauth_application, :owner => user)
assert_response :success
assert_template "oauth2_applications/edit"
assert_select "form", 1 do
- assert_select "input#doorkeeper_application_name", 1
- assert_select "textarea#doorkeeper_application_redirect_uri", 1
- assert_select "input#doorkeeper_application_confidential", 1
+ assert_select "input#oauth2_application_name", 1
+ assert_select "textarea#oauth2_application_redirect_uri", 1
+ assert_select "input#oauth2_application_confidential", 1
Oauth.scopes.each do |scope|
- assert_select "input#doorkeeper_application_scopes_#{scope.name}", 1
+ assert_select "input#oauth2_application_scopes_#{scope.name}", 1
end
end
end
assert_template "oauth2_applications/not_found"
put oauth_application_path(:id => client,
- :doorkeeper_application => {
+ :oauth2_application => {
:name => "New Name",
:redirect_uri => nil
})
assert_template "oauth2_applications/edit"
put oauth_application_path(:id => client,
- :doorkeeper_application => {
+ :oauth2_application => {
:name => "New Name",
:redirect_uri => "https://new.example.com/url"
})