使用Rails 3.1.3,我试图弄清楚为什么我们的计数器缓存在通过update_attributes更改父记录ID时没有正确更新.
class ExhibitorRegistration < ActiveRecord::Base
belongs_to :event, :counter_cache => true
end
class Event < ActiveRecord::Base
has_many :exhibitor_registrations, :dependent => :destroy
end
describe ExhibitorRegistration do
it 'correctly maintains the counter cache on events' do
event = Factory(:event)
other_event = Factory(:event)
registration = Factory(:exhibitor_registration, :event => event)
event.reload
event.exhibitor_registrations_count.should == 1
registration.update_attributes(:event_id => other_event.id)
event.reload
event.exhibitor_registrations_count.should == 0
other_event.reload
other_event.exhibitor_registrations_count.should == 1
end
end
Run Code Online (Sandbox Code Playgroud)
此规范失败,表明事件上的计数器缓存未递减.
1) ExhibitorRegistration correctly maintains the counter cache on events
Failure/Error: event.exhibitor_registrations_count.should == 0
expected: 0
got: …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的React.js组件,该组件使用“阅读更多” /“阅读更少”功能来修饰一长段标记。
我在Jest上进行了一些测试,但是,我无法断言DOM元素的高度正在增加到原始内容的大小。
在Jest测试环境中,我对getDOMNode()。scrollHeight的调用似乎未返回任何内容。
这是代码和测试失败的存储库链接:https : //github.com/mguterl/react-jest-dom-question
下面是说明相同问题的代码和测试的简化版本:
var ReadMore = React.createClass({
getInitialState: function() {
return {
style: {
height: '0px'
}
}
},
render: function() {
return (
<div>
<div ref='content' className='read-more__content' style={this.state.style} dangerouslySetInnerHTML={{__html: this.props.content}} />
<a onClick={this.expand} href='#'>Expand</a>
</div>
);
},
expand: function() {
// This call to scrollHeight doesn't return anything when testing.
var height = this.refs.content.getDOMNode().scrollHeight;
this.setState({
style: {
height: height
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
jest.dontMock('../ReadMore');
global.React = require('react/addons');
var TestUtils = React.addons.TestUtils; …Run Code Online (Sandbox Code Playgroud) 我们有一个相当大的rails应用程序,我在unicorn.log中启动了这个输出:
#:0xc644248>#:0xc644248>#:0xc4f06e4>#:0xc4f06e4>#:0xca481b4>#:0xca481b4>#:0xc53f604>#:0xc53f604>#:0xcd7a60c>#:0xcd7a60c>#:0xc5df2f8>#:0xc5df2f8>#:0xc69fd00>#:0xc69fd00>#:0xc560ae8>#:0xc560ae8>
在我看来,可能有一个杂散的Kernel.puts方法调用某处,但我一直在搜索几个小时,但找不到它.
任何人都有跟踪此类内容的提示吗?