about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-02-29 19:42:08 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-02-29 19:42:08 +0100
commit0e8f59c16fcb21301c736ecbc4424cb4c5388c42 (patch)
tree344ac1e0b2d165ba4fe3870f786e854710970ce1 /spec
parent11ff92c9d7b27c2c9ed86f649aef8d956cc8b989 (diff)
Refactoring Grape API methods into normal controllers & other things
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/accounts_controller_spec.rb17
-rw-r--r--spec/controllers/api/salmon_controller_spec.rb7
-rw-r--r--spec/controllers/api/subscriptions_controller_spec.rb11
-rw-r--r--spec/controllers/atom_controller_spec.rb11
-rw-r--r--spec/controllers/home_controller_spec.rb5
-rw-r--r--spec/controllers/profile_controller_spec.rb11
-rw-r--r--spec/controllers/stream_entries_controller_spec.rb18
-rw-r--r--spec/controllers/xrd_controller_spec.rb17
-rw-r--r--spec/helpers/accounts_helper_spec.rb15
-rw-r--r--spec/helpers/api/salmon_helper_spec.rb15
-rw-r--r--spec/helpers/api/subscriptions_helper_spec.rb15
-rw-r--r--spec/helpers/application_helper_spec.rb14
-rw-r--r--spec/helpers/atom_builder_helper_spec.rb (renamed from spec/helpers/atom_helper_spec.rb)2
-rw-r--r--spec/helpers/stream_entries_helper_spec.rb (renamed from spec/helpers/profile_helper_spec.rb)2
14 files changed, 119 insertions, 41 deletions
diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb
new file mode 100644
index 000000000..b1646b314
--- /dev/null
+++ b/spec/controllers/accounts_controller_spec.rb
@@ -0,0 +1,17 @@
+require 'rails_helper'
+
+RSpec.describe AccountsController, type: :controller do
+  let(:alice)  { Fabricate(:account, username: 'alice') }
+
+  describe 'GET #show' do
+    it 'returns 200' do
+      get :show, username: alice.username
+      expect(response).to have_http_status(:success)
+    end
+
+    it 'returns 200 with Atom' do
+      get :show, username: alice.username, format: 'atom'
+      expect(response).to have_http_status(:success)
+    end
+  end
+end
diff --git a/spec/controllers/api/salmon_controller_spec.rb b/spec/controllers/api/salmon_controller_spec.rb
new file mode 100644
index 000000000..e81ad12ad
--- /dev/null
+++ b/spec/controllers/api/salmon_controller_spec.rb
@@ -0,0 +1,7 @@
+require 'rails_helper'
+
+RSpec.describe Api::SalmonController, type: :controller do
+  describe 'POST #update' do
+    pending
+  end
+end
diff --git a/spec/controllers/api/subscriptions_controller_spec.rb b/spec/controllers/api/subscriptions_controller_spec.rb
new file mode 100644
index 000000000..16995c687
--- /dev/null
+++ b/spec/controllers/api/subscriptions_controller_spec.rb
@@ -0,0 +1,11 @@
+require 'rails_helper'
+
+RSpec.describe Api::SubscriptionsController, type: :controller do
+  describe 'GET #show' do
+    pending
+  end
+
+  describe 'POST #update' do
+    pending
+  end
+end
diff --git a/spec/controllers/atom_controller_spec.rb b/spec/controllers/atom_controller_spec.rb
deleted file mode 100644
index 6f04ad347..000000000
--- a/spec/controllers/atom_controller_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe AtomController, type: :controller do
-  describe 'GET #user_stream' do
-    pending
-  end
-
-  describe 'GET #entry' do
-    pending
-  end
-end
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index e609ab6be..7eaa43df7 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -2,6 +2,9 @@ require 'rails_helper'
 
 RSpec.describe HomeController, type: :controller do
   describe 'GET #index' do
-    pending
+    it 'returns 200' do
+      get :index
+      expect(response).to have_http_status(:success)
+    end
   end
 end
diff --git a/spec/controllers/profile_controller_spec.rb b/spec/controllers/profile_controller_spec.rb
deleted file mode 100644
index e4d124e29..000000000
--- a/spec/controllers/profile_controller_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe ProfileController, type: :controller do
-  describe 'GET #show' do
-    pending
-  end
-
-  describe 'GET #entry' do
-    pending
-  end
-end
diff --git a/spec/controllers/stream_entries_controller_spec.rb b/spec/controllers/stream_entries_controller_spec.rb
new file mode 100644
index 000000000..5fa3195eb
--- /dev/null
+++ b/spec/controllers/stream_entries_controller_spec.rb
@@ -0,0 +1,18 @@
+require 'rails_helper'
+
+RSpec.describe StreamEntriesController, type: :controller do
+  let(:alice)  { Fabricate(:account, username: 'alice') }
+  let(:status) { Fabricate(:status, account: alice) }
+
+  describe 'GET #show' do
+    it 'returns 200 with HTML' do
+      get :show, account_username: alice.username, id: status.stream_entry.id
+      expect(response).to have_http_status(:success)
+    end
+
+    it 'returns 200 with Atom' do
+      get :show, account_username: alice.username, id: status.stream_entry.id, format: 'atom'
+      expect(response).to have_http_status(:success)
+    end
+  end
+end
diff --git a/spec/controllers/xrd_controller_spec.rb b/spec/controllers/xrd_controller_spec.rb
index 669c02c40..a74b5c143 100644
--- a/spec/controllers/xrd_controller_spec.rb
+++ b/spec/controllers/xrd_controller_spec.rb
@@ -2,10 +2,23 @@ require 'rails_helper'
 
 RSpec.describe XrdController, type: :controller do
   describe 'GET #host_meta' do
-    pending
+    it 'returns 200' do
+      get :host_meta
+      expect(response).to have_http_status(:success)
+    end
   end
 
   describe 'GET #webfinger' do
-    pending
+    let(:alice) { Fabricate(:account, username: 'alice') }
+
+    it 'returns 200 when account can be found' do
+      get :webfinger, resource: "acct:#{alice.username}@anything.com"
+      expect(response).to have_http_status(:success)
+    end
+
+    it 'returns 404 when account cannot be found' do
+      get :webfinger, resource: 'acct:not@existing.com'
+      expect(response).to have_http_status(:not_found)
+    end
   end
 end
diff --git a/spec/helpers/accounts_helper_spec.rb b/spec/helpers/accounts_helper_spec.rb
new file mode 100644
index 000000000..c80b4f697
--- /dev/null
+++ b/spec/helpers/accounts_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the AccountsHelper. For example:
+#
+# describe AccountsHelper do
+#   describe "string concat" do
+#     it "concats two strings with spaces" do
+#       expect(helper.concat_strings("this","that")).to eq("this that")
+#     end
+#   end
+# end
+RSpec.describe AccountsHelper, type: :helper do
+  pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/api/salmon_helper_spec.rb b/spec/helpers/api/salmon_helper_spec.rb
new file mode 100644
index 000000000..9888d9121
--- /dev/null
+++ b/spec/helpers/api/salmon_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the Api::SalmonHelper. For example:
+#
+# describe Api::SalmonHelper do
+#   describe "string concat" do
+#     it "concats two strings with spaces" do
+#       expect(helper.concat_strings("this","that")).to eq("this that")
+#     end
+#   end
+# end
+RSpec.describe Api::SalmonHelper, type: :helper do
+  pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/api/subscriptions_helper_spec.rb b/spec/helpers/api/subscriptions_helper_spec.rb
new file mode 100644
index 000000000..a50196346
--- /dev/null
+++ b/spec/helpers/api/subscriptions_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the Api::SubscriptionsHelper. For example:
+#
+# describe Api::SubscriptionsHelper do
+#   describe "string concat" do
+#     it "concats two strings with spaces" do
+#       expect(helper.concat_strings("this","that")).to eq("this that")
+#     end
+#   end
+# end
+RSpec.describe Api::SubscriptionsHelper, type: :helper do
+  pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 0599c46e6..b36954b78 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -28,18 +28,4 @@ RSpec.describe ApplicationHelper, type: :helper do
       expect(helper.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false
     end
   end
-
-  describe '#add_base_url_prefix' do
-    it 'returns full API URL from base to suffix' do
-      expect(helper.add_base_url_prefix('test')).to eql "#{root_url}api/test"
-    end
-  end
-
-  describe '#profile_url' do
-    pending
-  end
-
-  describe '#status_url' do
-    pending
-  end
 end
diff --git a/spec/helpers/atom_helper_spec.rb b/spec/helpers/atom_builder_helper_spec.rb
index d52f36f83..04dda6f37 100644
--- a/spec/helpers/atom_helper_spec.rb
+++ b/spec/helpers/atom_builder_helper_spec.rb
@@ -1,6 +1,6 @@
 require 'rails_helper'
 
-RSpec.describe AtomHelper, type: :helper do
+RSpec.describe AtomBuilderHelper, type: :helper do
   describe '#stream_updated_at' do
     pending
   end
diff --git a/spec/helpers/profile_helper_spec.rb b/spec/helpers/stream_entries_helper_spec.rb
index 77712105c..d2215e1eb 100644
--- a/spec/helpers/profile_helper_spec.rb
+++ b/spec/helpers/stream_entries_helper_spec.rb
@@ -1,6 +1,6 @@
 require 'rails_helper'
 
-RSpec.describe ProfileHelper, type: :helper do
+RSpec.describe StreamEntriesHelper, type: :helper do
   describe '#display_name' do
     pending
   end