about summary refs log tree commit diff
path: root/spec/controllers/api/v1/notifications_controller_spec.rb
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-05-19 17:32:37 -0400
committerEugen Rochko <eugen@zeonfederated.com>2017-05-19 23:32:37 +0200
commitb6f6152e263cdf12f61f9ae3d65c351a4dec7c61 (patch)
tree9286a168c505f9840ecf3f7b1a5e9900b98d748a /spec/controllers/api/v1/notifications_controller_spec.rb
parentf8ee136c29aa7185fe05450090229d428986e529 (diff)
Add coverage for api/v1 controllers (#3155)
Diffstat (limited to 'spec/controllers/api/v1/notifications_controller_spec.rb')
-rw-r--r--spec/controllers/api/v1/notifications_controller_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/controllers/api/v1/notifications_controller_spec.rb b/spec/controllers/api/v1/notifications_controller_spec.rb
index e3c953094..e06230913 100644
--- a/spec/controllers/api/v1/notifications_controller_spec.rb
+++ b/spec/controllers/api/v1/notifications_controller_spec.rb
@@ -11,6 +11,35 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
     allow(controller).to receive(:doorkeeper_token) { token }
   end
 
+  describe 'GET #show' do
+    it 'returns http success' do
+      notification = Fabricate(:notification, account: user.account)
+      get :show, params: { id: notification.id }
+
+      expect(response).to have_http_status(:success)
+    end
+  end
+
+  describe 'POST #dismiss' do
+    it 'destroys the notification' do
+      notification = Fabricate(:notification, account: user.account)
+      post :dismiss, params: { id: notification.id }
+
+      expect(response).to have_http_status(:success)
+      expect { notification.reload }.to raise_error(ActiveRecord::RecordNotFound)
+    end
+  end
+
+  describe 'POST #clear' do
+    it 'clears notifications for the account' do
+      notification = Fabricate(:notification, account: user.account)
+      post :clear
+
+      expect(notification.account.reload.notifications).to be_empty
+      expect(response).to have_http_status(:success)
+    end
+  end
+
   describe 'GET #index' do
     before do
       first_status = PostStatusService.new.call(user.account, 'Test')