about summary refs log tree commit diff
path: root/spec/controllers
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2017-05-23 09:53:01 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-23 02:53:01 +0200
commit8fd174298df3fea60a4efe958fca9c1946633e10 (patch)
tree21e2ddcbc759039c181116e23c577cb362f12fcf /spec/controllers
parent9afd7dadbf5ffa6ad0686da197b927230a101bea (diff)
Cover AccountsController more in spec (#3229)
* Introduce recent scope to Status and StreamEntry

Introduce recent scope to Status and StreamEntry as Account has.

* Cover AccountsController more in AccountsController
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/accounts_controller_spec.rb39
1 files changed, 33 insertions, 6 deletions
diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb
index 94d10d78f..447e2dd53 100644
--- a/spec/controllers/accounts_controller_spec.rb
+++ b/spec/controllers/accounts_controller_spec.rb
@@ -6,17 +6,29 @@ RSpec.describe AccountsController, type: :controller do
   let(:alice)  { Fabricate(:account, username: 'alice') }
 
   describe 'GET #show' do
+    let!(:status1) { Status.create!(account: alice, text: 'Hello world') }
+    let!(:status2) { Status.create!(account: alice, text: 'Boop', thread: status1) }
+    let!(:status3) { Status.create!(account: alice, text: 'Picture!') }
+    let!(:status4) { Status.create!(account: alice, text: 'Mentioning @alice') }
+
     before do
-      status1 = Status.create!(account: alice, text: 'Hello world')
-      Status.create!(account: alice, text: 'Boop', thread: status1)
-      status3 = Status.create!(account: alice, text: 'Picture!')
       status3.media_attachments.create!(account: alice, file: fixture_file_upload('files/attachment.jpg', 'image/jpeg'))
-      Status.create!(account: alice, text: 'Mentioning @alice')
     end
 
     context 'atom' do
       before do
-        get :show, params: { username: alice.username }, format: 'atom'
+        get :show, params: { username: alice.username, max_id: status4.stream_entry.id, since_id: status1.stream_entry.id }, format: 'atom'
+      end
+
+      it 'assigns @account' do
+        expect(assigns(:account)).to eq alice
+      end
+
+      it 'assigns @entries' do
+        entries = assigns(:entries).to_a
+        expect(entries.size).to eq 2
+        expect(entries[0].status).to eq status3
+        expect(entries[1].status).to eq status2
       end
 
       it 'returns http success with Atom' do
@@ -29,6 +41,10 @@ RSpec.describe AccountsController, type: :controller do
         get :show, params: { username: alice.username }, format: 'activitystreams2'
       end
 
+      it 'assigns @account' do
+        expect(assigns(:account)).to eq alice
+      end
+
       it 'returns http success with Activity Streams 2.0' do
         expect(response).to have_http_status(:success)
       end
@@ -36,7 +52,18 @@ RSpec.describe AccountsController, type: :controller do
 
     context 'html' do
       before do
-        get :show, params: { username: alice.username }
+        get :show, params: { username: alice.username, max_id: status4.id, since_id: status1.id }
+      end
+
+      it 'assigns @account' do
+        expect(assigns(:account)).to eq alice
+      end
+
+      it 'assigns @statuses' do
+        statuses = assigns(:statuses).to_a
+        expect(statuses.size).to eq 2
+        expect(statuses[0]).to eq status3
+        expect(statuses[1]).to eq status2
       end
 
       it 'returns http success' do