我正在尝试检查管理员是否在Rspec测试中注销.但通常的signed_in?方法不能从rspec中看出,也不是RSpec Devise Helpers的一部分.
这样的事情就是我所拥有的
before (:each) do
@admin = FactoryGirl.create(:administrator)
sign_in @admin
end
it "should allow the admin to sign out" do
sign_out @admin
#@admin.should be_nil
#@admin.signed_in?.should be_false
administrator_signed_in?.should be_false
end
Run Code Online (Sandbox Code Playgroud)
有没有办法检查管理员的会话,看看他是否真的登录?
应该足够简单但可能不是.
在Android 3.0+中使用操作栏时,您可以选择以XML或代码定义菜单项.我更喜欢用xml编写它们,因为动作条感觉基于UI而不是功能.
平均每天,您可以使用它将xml扩展到菜单中
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Menu is defined inside 'res/menu/...xml
getMenuInflater().inflate(R.menu.activity_home, menu);
return true;
}
Run Code Online (Sandbox Code Playgroud)
你的XML文件看起来像这样
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/menu_settings"/>
<item
android:id="@+id/menu_item_menu"
android:icon="@drawable/menu_off_128"
android:showAsAction="ifRoom|withText"
android:title="@string/inbox_string"/>
<item
android:id="@+id/menu_item_gallery"
android:icon="@drawable/gallery_off_128"
android:showAsAction="ifRoom|withText"
android:title="@string/gallery_string"/>
<item
android:id="@+id/menu_item_inbox"
android:icon="@drawable/inbox_off_128"
android:showAsAction="ifRoom|withText"
android:title="@string/inbox_string"/>
<item
android:id="@+id/menu_item_contact"
android:icon="@drawable/phone_off_128"
android:showAsAction="ifRoom|withText"
android:title="@string/contact_string"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
现在,我面临着使动作栏向后兼容的问题,而动作障碍似乎是最令人愉快的使用和流行.所以我用actionbarsherlock尝试了上面的内容,遗憾的是有编译时问题.
也就是说,inflater返回的Menu类来自'Android.view.menu'而不是'com.actionbarsherlock.menu'.我在github上挖掘了样本,但是所有这些都有代码中定义的菜单.
那么有没有人想让actionbarsherlock菜单使用基于XML文件的布局?
android menu backwards-compatibility actionbarsherlock android-actionbar