Sha256: 1c0447d527b3f048e349811bb8abb6093228b767744adf04c20403143c2764cb

Contents?: true

Size: 1 KB

Versions: 47

Compression:

Stored size: 1 KB

Contents

require "spec_helper"

shared_examples "a BulkPostsAllowOnlyExistingForm" do

  it "1. Tabless model 'BulkPostsAllowOnlyNew' only accepts editings 'Post' requests and ignores new requests." do
    params = {
      bulk_post: {
        posts_attributes: {
          "0" => { title: "new post" },
          "1" => { id: 1, title: 'altered post' },
          "2" => { id: 2, title: '', _destroy: true }
        }
      }
    }

    Post.create(title: "My title1")
    Post.create(title: "My title2")
    Post.all.count.should == 2
    Post.find_by_id(1).title.should == 'My title1'
    Post.find_by_id(2).title.should == 'My title2'

    buld_posts_form = described_class.new(params[:bulk_post])
    buld_posts_form.save
    
    Post.all.count.should == 1
    Post.first.title.should == 'altered post'
  end

end

describe BulkPostsAllowOnlyExistingForm::Base do
  it_behaves_like 'a BulkPostsAllowOnlyExistingForm'
end

describe BulkPostsAllowOnlyExistingForm::Explicit do
  it_behaves_like 'a BulkPostsAllowOnlyExistingForm'
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
object_attorney-2.10.12 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.10.11 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.10.10 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.10.9 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.10.7 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.10.6 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.10.5 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.10.3 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.10.2 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.10.1 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.9.4 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.9.3 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.9.2 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.9.0 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.8.1 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.8.0 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.6.12 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.6.11 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.6.10 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
object_attorney-2.6.9 spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb