diff options
author | Azul <azul@riseup.net> | 2016-05-18 21:00:42 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-05-20 16:35:55 +0200 |
commit | e542a3056c27fd662ef767b6720861035f6dbb1c (patch) | |
tree | 45d0d16069a7820a58583423956c8cc4f5f64819 /test/functional/api/messages_controller_test.rb | |
parent | 83f59164fc069f2593cf6babbc18638d9a68c9a3 (diff) |
api: set defaults for version in routes
This way we do not need to specify it all the times.
In the functional tests defaults do not get added automatically.
Introduced api_{get,put,post,delete} to add format and version default.
One to two functional tests failing, everything else passes.
Diffstat (limited to 'test/functional/api/messages_controller_test.rb')
-rw-r--r-- | test/functional/api/messages_controller_test.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/functional/api/messages_controller_test.rb b/test/functional/api/messages_controller_test.rb index 01641d4..e586980 100644 --- a/test/functional/api/messages_controller_test.rb +++ b/test/functional/api/messages_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class Api::MessagesControllerTest < ActionController::TestCase +class Api::MessagesControllerTest < ApiControllerTest setup do @user = FactoryGirl.build(:user) @@ -13,7 +13,7 @@ class Api::MessagesControllerTest < ActionController::TestCase test "get the motd" do with_config("customization_directory" => Rails.root+'test/files') do login @user - get :index, :locale => 'es' + api_get :index, :locale => 'es' body = JSON.parse(response.body) message1 = "<p>\"This\" is a <strong>very</strong> fine message. <a href=\"https://bitmask.net\">https://bitmask.net</a></p>\n" assert_equal 2, body.size, 'there should be two messages' @@ -24,7 +24,7 @@ class Api::MessagesControllerTest < ActionController::TestCase test "get localized motd" do with_config("customization_directory" => Rails.root+'test/files') do login @user - get :index, :locale => 'de' + api_get :index, :locale => 'de' body = JSON.parse(response.body) message1 = "<p>Dies ist eine sehr feine Nachricht. <a href=\"https://bitmask.net\">https://bitmask.net</a></p>\n" assert_equal message1, body.first["text"], 'first message text should match files/motd/1.de.md' @@ -33,7 +33,7 @@ class Api::MessagesControllerTest < ActionController::TestCase test "get empty motd" do login @user - get :index + api_get :index assert_equal "[]", response.body, "motd response should be empty if no motd directory exists" end @@ -58,7 +58,7 @@ class Api::MessagesControllerTest < ActionController::TestCase test "get messages for user" do login @user - get :index + api_get :index assert response.body.include? @message.text assert response.body.include? @message.id end @@ -78,7 +78,7 @@ class Api::MessagesControllerTest < ActionController::TestCase login @user put :update, :id => @message.id @message.reload - get :index + api_get :index assert !(response.body.include? @message.text) assert !(response.body.include? @message.id) end @@ -91,7 +91,7 @@ class Api::MessagesControllerTest < ActionController::TestCase end test "fails if not authenticated" do - get :index, :format => :json + api_get :index, :format => :json assert_login_required end =end |