Sha256: 1752ca592a34d1d7611bf2a012b612e2c5a2d33889d04186e290c5e57fda14c6

Contents?: true

Size: 1.56 KB

Versions: 19

Compression:

Stored size: 1.56 KB

Contents

describe Card::Set::Type::NotificationTemplate do
  include ActionController::TestCase::Behavior
  before do
    @routes = Decko::Engine.routes
    @controller = CardController.new
    login_as "joe_user"
    create "A+*self+*on update",
           type_id: Card::PointerID,
           content: "[[success]]"
  end

  def notify
    Card::Auth.as_bot do
      post :update, params: { id: "~#{Card['A'].id}",
                              card: { "content" => "change" } },
                    xhr: true
    end
  end

  context "notification template without fields" do
    before do
      create "success", type_id: Card::NotificationTemplateID,
                        content: "success"
    end

    describe "#deliver" do
      it "is called on update" do
        notify_card = Card["success"]
        expect(notify_card).to receive(:deliver).once
        Card["A"].update_attributes! content: "change"
      end
    end

    it "shows notification" do
      notify
      expect(response.body).to have_tag "div.alert.alert-success" do
        with_text(/success/)
      end
    end
  end

  context "notification template with fields" do
    before do
      create "success",
             type_id: Card::NotificationTemplateID,
             content: "success",
             subfields: { contextual_class: "danger",
                          disappear: "1",
                          message: "failed" }
    end

    it "shows notification" do
      notify
      expect(response.body).to have_tag "div.alert.alert-danger._disappear" do
        with_text(/failed/)
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
card-1.94.1 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.94.0 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.13 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.12 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.11 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.10 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.9 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.8 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.7 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.6 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.5 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.4 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.3 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.2 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.1 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.93.0 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.92.2 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.92.1 mod/notifications/spec/set/type/notification_template_spec.rb
card-1.92 mod/notifications/spec/set/type/notification_template_spec.rb