summaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
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