about summary refs log tree commit diff
path: root/spec/controllers/api/v1/apps_controller_spec.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-27 16:58:23 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-27 16:59:08 +0200
commit4f9b7432dd4d323ac6cc4efceeae2efaffe62e7d (patch)
treeacae9e59bd6971885f7cb7b7ed45c4c9d1af4fca /spec/controllers/api/v1/apps_controller_spec.rb
parent3f75f522856954690d92358107e78bafd0db0baa (diff)
Fix #52 - Add API versioning (v1)
Diffstat (limited to 'spec/controllers/api/v1/apps_controller_spec.rb')
-rw-r--r--spec/controllers/api/v1/apps_controller_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/controllers/api/v1/apps_controller_spec.rb b/spec/controllers/api/v1/apps_controller_spec.rb
new file mode 100644
index 000000000..20a0755ff
--- /dev/null
+++ b/spec/controllers/api/v1/apps_controller_spec.rb
@@ -0,0 +1,26 @@
+require 'rails_helper'
+
+RSpec.describe Api::V1::AppsController, type: :controller do
+  render_views
+
+  describe 'POST #create' do
+    before do
+      post :create, params: { name: 'Test app', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob' }
+    end
+
+    it 'returns http success' do
+      expect(response).to have_http_status(:success)
+    end
+
+    it 'creates an OAuth app' do
+      expect(Doorkeeper::Application.find_by(name: 'Test app')).to_not be nil
+    end
+
+    it 'returns client ID and client secret' do
+      json = body_as_json
+
+      expect(json[:client_id]).to_not be_blank
+      expect(json[:client_secret]).to_not be_blank
+    end
+  end
+end