diff --git a/app/assets/javascripts/mobile/mobile_alert.js b/app/assets/javascripts/mobile/mobile_alert.js
new file mode 100644
index 000000000..67e23a58a
--- /dev/null
+++ b/app/assets/javascripts/mobile/mobile_alert.js
@@ -0,0 +1,19 @@
+(function() {
+ Diaspora.Mobile.Alert = {
+ _flash: function(message, type) {
+ var html = "
" +
+ "" +
+ message +
+ "
";
+ $("#flash-messages").append(html);
+ },
+
+ success: function(message) { this._flash(message, "success"); },
+
+ error: function(message) { this._flash(message, "danger"); }
+ };
+})();
diff --git a/spec/javascripts/mobile/mobile_alert_spec.js b/spec/javascripts/mobile/mobile_alert_spec.js
new file mode 100644
index 000000000..ffb789ef7
--- /dev/null
+++ b/spec/javascripts/mobile/mobile_alert_spec.js
@@ -0,0 +1,29 @@
+describe("Diaspora.Mobile.Alert", function() {
+ describe("_flash", function() {
+ beforeEach(function() {
+ spec.content().html("");
+ });
+
+ it("appends an alert to the #flash-messages div", function() {
+ Diaspora.Mobile.Alert._flash("Oh snap! You got an error!", "error-class");
+ expect($("#flash-messages .alert")).toHaveClass("alert-error-class");
+ expect($("#flash-messages .alert").text()).toBe("Oh snap! You got an error!");
+ });
+ });
+
+ describe("success", function() {
+ it("calls _flash", function() {
+ spyOn(Diaspora.Mobile.Alert, "_flash");
+ Diaspora.Mobile.Alert.success("Awesome!");
+ expect(Diaspora.Mobile.Alert._flash).toHaveBeenCalledWith("Awesome!", "success");
+ });
+ });
+
+ describe("error", function() {
+ it("calls _flash", function() {
+ spyOn(Diaspora.Mobile.Alert, "_flash");
+ Diaspora.Mobile.Alert.error("Oh noez!");
+ expect(Diaspora.Mobile.Alert._flash).toHaveBeenCalledWith("Oh noez!", "danger");
+ });
+ });
+});