summaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-04-01 02:25:36 -0700
committerelijah <elijah@riseup.net>2016-04-01 02:25:36 -0700
commit97ace0f06ab72b82ed0be4ca5c481f4f16a3c847 (patch)
treeea4f0ca7087a0c668463c0cebff8825ac479fb3d /test/functional
parentbe5efb57dc9b282a31cf29c9eac27cb5a7e7ac2f (diff)
api: added super simple motd, closes #7866
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/v1/messages_controller_test.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/functional/v1/messages_controller_test.rb b/test/functional/v1/messages_controller_test.rb
index 720d862..67f34a1 100644
--- a/test/functional/v1/messages_controller_test.rb
+++ b/test/functional/v1/messages_controller_test.rb
@@ -3,6 +3,47 @@ require 'test_helper'
class V1::MessagesControllerTest < ActionController::TestCase
setup do
+ @user = FactoryGirl.build(:user)
+ @user.save
+ end
+
+ # NOTE: the available languages for test are :en and :de
+ # so :es will result in english response.
+
+ test "get the motd" do
+ with_config("customization_directory" => Rails.root+'test/files') do
+ login @user
+ get :index, :locale => 'es'
+ body = JSON.parse(response.body)
+ p 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'
+ assert_equal message1, body.first["text"], 'first message text should match files/motd/1.en.md'
+ end
+ end
+
+ test "get localized motd" do
+ with_config("customization_directory" => Rails.root+'test/files') do
+ login @user
+ 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'
+ end
+ end
+
+ test "get empty motd" do
+ login @user
+ get :index
+ assert_equal "[]", response.body, "motd response should be empty if no motd directory exists"
+ end
+
+ ##
+ ## For now, only the static file MOTD is supported, not messages in the db.
+ ## so, this is disabled:
+ ##
+=begin
+ setup do
InviteCodeValidator.any_instance.stubs(:validate)
@user = FactoryGirl.build(:user)
@user.save
@@ -54,5 +95,6 @@ class V1::MessagesControllerTest < ActionController::TestCase
get :index, :format => :json
assert_login_required
end
+=end
end