Sha256: a5743e40dba320726b222aec9a03b4402104441319f3e9026f3ed6216928cd9b

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'
require 'test_components'
require 'rspec-steps'

describe "saving during commit", js: true do

  before(:each) do
    require 'pusher'
    require 'pusher-fake'
    Pusher.app_id = "MY_TEST_ID"
    Pusher.key =    "MY_TEST_KEY"
    Pusher.secret = "MY_TEST_SECRET"
    require "pusher-fake/support/base"

    Hyperloop.configuration do |config|
      config.transport = :pusher
      config.channel_prefix = "synchromesh"
      config.opts = {app_id: Pusher.app_id, key: Pusher.key, secret: Pusher.secret}.merge(PusherFake.configuration.web_options)
    end

    class CommitIssue < ActiveRecord::Base
      def self.build_tables
        connection.create_table :commit_issues, force: true do |t|
          t.string :name
          t.timestamps
        end
      end
    end

    isomorphic do
      class CommitIssue < ActiveRecord::Base
        after_create :save_again
        def save_again
          save
        end
      end
    end

    CommitIssue.build_tables rescue nil

    stub_const 'ApplicationPolicy', Class.new
    ApplicationPolicy.class_eval do
      always_allow_connection
      regulate_all_broadcasts { |policy| policy.send_all }
      allow_change(to: :all, on: [:create, :update, :destroy]) { true }
    end
    size_window(:small, :portrait)
  end

  it "broadcast even if saving during after_save" do
    CommitIssue.create(name: 1)
    mount "CommitIssueTest" do
      class CommitIssueTest < React::Component::Base
        render do
          "all: [#{CommitIssue.all.pluck(:name)}]"
        end
      end
    end
    page.should have_content('all: [1]')
    CommitIssue.create(name: 2)
    page.should have_content('all: [1,2]')
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyper-mesh-0.6.0 spec/batch4/saving_during_commit_spec.rb
hyper-mesh-0.5.4 spec/batch4/saving_during_commit_spec.rb