about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authornullkal <nullkal@users.noreply.github.com>2017-08-23 22:16:20 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-08-23 15:16:20 +0200
commit80393a23d0a0c296d4356a2a21cf8504435265bf (patch)
tree6d0bdc6c4e0b3d600c6a786c5e66e1e5ba254114 /spec
parent8d23667536cec65292302774b3816467ad427a32 (diff)
Use checkboxes for application scope setting (#4671)
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/settings/applications_controller_spec.rb30
1 files changed, 26 insertions, 4 deletions
diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb
index 7902a4334..ca66f8d23 100644
--- a/spec/controllers/settings/applications_controller_spec.rb
+++ b/spec/controllers/settings/applications_controller_spec.rb
@@ -45,7 +45,7 @@ describe Settings::ApplicationsController do
   end
 
   describe 'POST #create' do
-    context 'success' do
+    context 'success (passed scopes as a String)' do
       def call_create
         post :create, params: {
                doorkeeper_application: {
@@ -61,7 +61,29 @@ describe Settings::ApplicationsController do
       it 'creates an entry in the database' do
         expect { call_create }.to change(Doorkeeper::Application, :count)
       end
-      
+
+      it 'redirects back to applications page' do
+        expect(call_create).to redirect_to(settings_applications_path)
+      end
+    end
+
+    context 'success (passed scopes as an Array)' do
+      def call_create
+        post :create, params: {
+               doorkeeper_application: {
+                 name: 'My New App',
+                 redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
+                 website: 'http://google.com',
+                 scopes: [ 'read', 'write', 'follow' ]
+               }
+             }
+        response
+      end
+
+      it 'creates an entry in the database' do
+        expect { call_create }.to change(Doorkeeper::Application, :count)
+      end
+
       it 'redirects back to applications page' do
         expect(call_create).to redirect_to(settings_applications_path)
       end
@@ -74,7 +96,7 @@ describe Settings::ApplicationsController do
                  name: '',
                  redirect_uri: '',
                  website: '',
-                 scopes: ''
+                 scopes: []
                }
              }
       end
@@ -123,7 +145,7 @@ describe Settings::ApplicationsController do
                   name: '',
                   redirect_uri: '',
                   website: '',
-                  scopes: ''
+                  scopes: []
                 }
               }
       end