我有一个Phrase类has_many Phrase的Translation.
class Phrase < ActiveRecord::Base
has_many :translatabilities
has_many :translations, through: :translatabilities
has_many :inverse_translatabilities, class_name: "Translatability", foreign_key: "translation_id"
has_many :inverse_translations, through: :inverse_translatabilities, source: :phrase
accepts_nested_attributes_for :translatabilities
end
Run Code Online (Sandbox Code Playgroud)
class PhrasesController < ApplicationController
def index
@phrases = Phrase.all.page params[:page]
@translations = @phrases.count.times.map do |i|
translation = Phrase.new
translation.translatabilities.build
translation
end
end
end
Run Code Online (Sandbox Code Playgroud)
我想为每个"短语"添加"可译性"形式.
<table>
<tbody>
<% @phrases.each do |phrase| %>
<tr>
<td><%= phrase.text %></td>
</tr>
<tr>
<td>
<%= form_for @translations …Run Code Online (Sandbox Code Playgroud) Git push on heroku指向一个不存在的git存储库.
git.heroku.com/secure-reef-1722.git这是我们运行heroku create命令时创建的存储库.
但是当我们运行'push'命令($ git push heroku master)时,它说
远程:!没有像沸腾入口6957这样的应用程序.致命:未找到存储库' https://git.heroku.com/boiling-inlet-6957.git/
当我们运行$ git remote -v时,我们也无法看到新的存储库
Run Code Online (Sandbox Code Playgroud)heroku https://git.heroku.com/boiling-inlet-6957.git (fetch) heroku https://git.heroku.com/boiling-inlet-6957.git (push) origin git@bitbucket.org:coderz$/toy_app.git (fetch) origin git@bitbucket.org:coderz$/toy_app.git (push)
现在我们无法将文件推送到新的heroku git存储库(git.heroku.com/secure-reef-1722.git)
请帮助我们.提前致谢.
完整的命令序列
coderz$:~/workspace/toy_app (master) $ heroku create
Creating secure-reef-1722... done, stack is cedar-14
https://secure-reef-1722.herokuapp.com/ | https://git.heroku.com/secure-reef-1722.git
coderz$:~/workspace/toy_app (master) $ git push heroku master
remote: ! No such app as boiling-inlet-6957.
fatal: repository 'https://git.heroku.com/boiling-inlet-6957.git/' not found
coderz$:~/workspace/toy_app (master) $ git remote -v
heroku …Run Code Online (Sandbox Code Playgroud) 我在CakePHP中进行单元测试时遇到了一些问题,特别是在测试数据库插入/更新时.假设我有一个类似这样的模型:
class User {
var $name = 'User';
function updatePassword($data) {
return $this->updateAll($data);
}
}
class UserTestCase {
function testUpdatePassword() {
$tmpData = array(
'User' => array(
'password' => sha1(uniqid('', true)) //dummy pass
);
$result = $this->User->updatePassword($tmpData);
$this->assertTrue($result);
}
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是在我的测试用例中:
这个例子似乎有点人为(我可以update在控制器中做一个没有创建额外模型方法的例子),但重点是,在测试更新/插入时,数据是虚拟数据,从表单检索的数据可能不同而且好处似乎并没有超过成本.
您对TDD和单元测试的方法表示赞赏,并且了解您通常会尝试为案例提供何种覆盖范围.
干杯