Sha256: 5b3cd083f7854952e9b59a24553b59fc2fb49a38aa556085bbcf5f275c7b51e9

Contents?: true

Size: 1.09 KB

Versions: 47

Compression:

Stored size: 1.09 KB

Contents

require "spec_helper"

shared_examples "a BulkPostsAllowOnlyNewForm" do

  it "1. Tabless model 'BulkPostsAllowOnlyNewForm' only accepts new 'Post' requests and ignores editing 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 == 3
    Post.find_by_id(1).title.should == 'My title1'
    Post.find_by_id(2).title.should == 'My title2'
    Post.find_by_id(3).title.should == 'new post'
  end

end

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

describe BulkPostsAllowOnlyNewForm::Explicit do
  it_behaves_like 'a BulkPostsAllowOnlyNewForm'
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_new_form_spec.rb
object_attorney-2.10.11 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.10.10 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.10.9 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.10.7 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.10.6 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.10.5 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.10.3 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.10.2 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.10.1 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.9.4 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.9.3 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.9.2 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.9.0 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.8.1 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.8.0 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.6.12 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.6.11 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.6.10 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
object_attorney-2.6.9 spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb