Я пытаюсь протестировать следующий сценарий:
- > У меня есть модель под названием Team, которая имеет смысл, когда она была создана пользователем. Поэтому каждый экземпляр Team должен быть связан с пользователем.
Чтобы проверить это, я сделал следующее:
describe Team do
...
it "should be associated with a user" do
no_user_team = Team.new(:user => nil)
no_user_team.should_not be_valid
end
...
end
Из-за меня меняет модель Team как:
class Team < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :name, :user
validates_presence_of :name
validates_presence_of :user
belongs_to :user
end
Это кажется вам правильным? Я просто беспокоюсь о том, чтобы сделать: user attribute доступным (массовое присвоение).