about summary refs log tree commit diff
path: root/spec/controllers/api
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-02-10 21:07:48 +0100
committerGitHub <noreply@github.com>2022-02-10 21:07:48 +0100
commit776e337b8d2aa66440bc4565617b5440ca781e1a (patch)
treed9d30c63622c58a343cea58a3509337630491609 /spec/controllers/api
parentd602c92b310545eb733a58caed49717341abe27c (diff)
parent642b5a621acdcae091f8bdb0f367018309616f71 (diff)
Merge pull request #1683 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/controllers/api')
-rw-r--r--spec/controllers/api/v1/media_controller_spec.rb21
-rw-r--r--spec/controllers/api/v1/statuses_controller_spec.rb17
2 files changed, 29 insertions, 9 deletions
diff --git a/spec/controllers/api/v1/media_controller_spec.rb b/spec/controllers/api/v1/media_controller_spec.rb
index d8d732630..a1f6ddb24 100644
--- a/spec/controllers/api/v1/media_controller_spec.rb
+++ b/spec/controllers/api/v1/media_controller_spec.rb
@@ -110,21 +110,24 @@ RSpec.describe Api::V1::MediaController, type: :controller do
       end
     end
 
-    context 'when not attached to a status' do
-      let(:media) { Fabricate(:media_attachment, status: nil, account: user.account) }
+    context 'when the author \'s' do
+      let(:status) { nil }
+      let(:media)  { Fabricate(:media_attachment, status: status, account: user.account) }
 
-      it 'updates the description' do
+      before do
         put :update, params: { id: media.id, description: 'Lorem ipsum!!!' }
+      end
+
+      it 'updates the description' do
         expect(media.reload.description).to eq 'Lorem ipsum!!!'
       end
-    end
 
-    context 'when attached to a status' do
-      let(:media) { Fabricate(:media_attachment, status: Fabricate(:status), account: user.account) }
+      context 'when already attached to a status' do
+        let(:status) { Fabricate(:status, account: user.account) }
 
-      it 'returns http not found' do
-        put :update, params: { id: media.id, description: 'Lorem ipsum!!!' }
-        expect(response).to have_http_status(:not_found)
+        it 'returns http not found' do
+          expect(response).to have_http_status(:not_found)
+        end
       end
     end
   end
diff --git a/spec/controllers/api/v1/statuses_controller_spec.rb b/spec/controllers/api/v1/statuses_controller_spec.rb
index 2679ab017..190dfad11 100644
--- a/spec/controllers/api/v1/statuses_controller_spec.rb
+++ b/spec/controllers/api/v1/statuses_controller_spec.rb
@@ -102,6 +102,23 @@ RSpec.describe Api::V1::StatusesController, type: :controller do
         expect(Status.find_by(id: status.id)).to be nil
       end
     end
+
+    describe 'PUT #update' do
+      let(:scopes) { 'write:statuses' }
+      let(:status) { Fabricate(:status, account: user.account) }
+
+      before do
+        put :update, params: { id: status.id, status: 'I am updated' }
+      end
+
+      it 'returns http success' do
+        expect(response).to have_http_status(200)
+      end
+
+      it 'updates the status' do
+        expect(status.reload.text).to eq 'I am updated'
+      end
+    end
   end
 
   context 'without an oauth token' do