summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/motd/1.de.md1
-rw-r--r--test/files/motd/1.en.md1
-rw-r--r--test/files/motd/1.es.md1
-rw-r--r--test/files/motd/2.en.md1
-rw-r--r--test/functional/v1/messages_controller_test.rb42
5 files changed, 46 insertions, 0 deletions
diff --git a/test/files/motd/1.de.md b/test/files/motd/1.de.md
new file mode 100644
index 0000000..89928b8
--- /dev/null
+++ b/test/files/motd/1.de.md
@@ -0,0 +1 @@
+Dies ist eine sehr feine Nachricht. https://bitmask.net \ No newline at end of file
diff --git a/test/files/motd/1.en.md b/test/files/motd/1.en.md
new file mode 100644
index 0000000..b4c451c
--- /dev/null
+++ b/test/files/motd/1.en.md
@@ -0,0 +1 @@
+"This" is a **very** fine message. https://bitmask.net \ No newline at end of file
diff --git a/test/files/motd/1.es.md b/test/files/motd/1.es.md
new file mode 100644
index 0000000..58dc05d
--- /dev/null
+++ b/test/files/motd/1.es.md
@@ -0,0 +1 @@
+Este es un mensaje **muy** fino. https://bitmask.net \ No newline at end of file
diff --git a/test/files/motd/2.en.md b/test/files/motd/2.en.md
new file mode 100644
index 0000000..fec4590
--- /dev/null
+++ b/test/files/motd/2.en.md
@@ -0,0 +1 @@
+Today's message is: "be excellent to each other" \ No newline at end of file
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