Sha256: 5055b0fe04317854dcccd96e48062a23a6bd595852004ee88bf442d56b102acd

Contents?: true

Size: 1.24 KB

Versions: 36

Compression:

Stored size: 1.24 KB

Contents

require_relative "../test_helper"

require "dummy/config/environment"
require "rails/test_help" # adds stuff like @routes, etc.

# require "haml"
# require "haml/template" # Thanks, Nathan!

#ActiveRecord::Schema.define do
  # create_table :artists do |table|
  #   table.column :name, :string
  #   table.timestamps
  # end

#   create_table :songs do |table|
#     table.column :title, :string
#     table.column :album_id, :integer
#   end

#   create_table :albums do |table|
#     table.column :title, :string
#   end
# end

class HasOneAndHasManyTest < ActionController::TestCase
  tests AlbumsController

  test "rendering 1-1 and 1-n" do
    get :new
    #puts @response.body

    assert_select "form"

    assert_select "form input" do |els|
      assert_select "[name=?]", "album[title]"
      assert_select "[name=?]", "album[songs_attributes][1][title]"
      assert_select "[name=?]", "album[songs_attributes][0][title]"
    end
  end

  test "submitting invalid form" do
    params = {
      "album"=>{"title"=>"Rio",
        "songs_attributes"=>{
          "0"=>{"name"=>""},
          "1"=>{"name"=>""}
      }}, "commit"=>"Create Album"}

    post :create, params

    assert_select "form"
    assert_select "li", "Songs title can&#39;t be blank"
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
reform-2.1.0 test/rails/integration_test.rb
reform-2.1.0.rc1 test/rails/integration_test.rb
reform-2.0.5 test/rails/integration_test.rb
reform-2.0.4 test/rails/integration_test.rb
reform-2.0.3 test/rails/integration_test.rb
reform-2.0.2 test/rails/integration_test.rb
reform-2.0.1 test/rails/integration_test.rb
reform-2.0.0 test/rails/integration_test.rb
reform-2.0.0.rc3 test/rails/integration_test.rb
reform-2.0.0.rc2 test/rails/integration_test.rb
reform-2.0.0.rc1 test/rails/integration_test.rb
reform-2.0.0.beta2 test/rails/integration_test.rb
reform-2.0.0.beta1 test/rails/integration_test.rb
reform-1.2.6 test/rails/integration_test.rb
reform-1.2.5 test/rails/integration_test.rb
reform-1.2.4 test/rails/integration_test.rb
reform-1.2.3 test/rails/integration_test.rb
reform-1.2.2 test/rails/integration_test.rb
reform-1.2.1 test/rails/integration_test.rb
reform-1.2.0.beta2 test/rails/integration_test.rb