Rails: Check Pundit authorization in RSpec
Pundit provide two helper methods to help you ensure the actions are authorized/scoped: verify_authorized
and verify_policy_scoped
. They are meant to be used in an after_action
hook.
As the check is made after the action, I see no point of using it in production, so I use it in RSpec:
# rails_helper.rb
# ...
config.before(:suite) do
FactoryBot.create :user, :known
ApplicationController.send(:after_action, :verify_authorized, {except: [:index]})
ApplicationController.send(:after_action, :verify_policy_scoped, {only: [:index]})
end
# ...
This way, it's still checked during all the tests using controllers.
Rail: sending emails via a rake task won't work if you use the_mail.deliver_later
. Use the_mail.deliver
, instead.
Keep in mind that .deliver
will be blocking in the context of the Rails server.
I heard that finding names for projects is "the hardest thing in development, after cache invaliadation". And that's right.
"Site compare" was a bad name because of two things: it compares sites, that's true. But it does not compare sites. So that's false.
"Capyxel"? After all, that does not mean anything, but it's about Capybara and pixels. Without being too obvious. So why not?
After testing Vuex(3.0.1) in a Nativescript-vue (2.0) app I noticed that when using ModalView
s or ListView
s,
$store
is not available in the list items components or modal component. For now, use a StackLayout
for lists and I pass the $store
as a prop to the ModalView
:
<!-- Instead of a ListView -->
<StackLayout class="list-group">
<MyComponent v-for="item in items" :item="item" :key="item.id" class="list-group-item"/>
</StackLayout>
In MyComponent
, the method to open the modal is like:
import ItemForm from '../forms/ItemForm'
export default {
name: 'MyComponent',
props: {
item: { required: true, type: Object },
},
methods: {
openForm () {
const props = {item: this.item, store: this.$store} // props for ItemForm
this.$showModal(ItemForm, { props }) // Show ItemForm as a ModalView
},
},
}
This content might not be appropriate for every situation.
Following
VueX Modulator - Part 1: generating VueX modules
(en)
I tested the "modulator" on a Nativescript-vue application and it works well.
Use it like this:
// app/store.js
import Vue from 'nativescript-vue'
import Vuex from 'vuex'
import Modulator from './modulator'
Vue.use(Vuex)
export default new Vuex.Store({
state: {},
modules: {
users: Modulator.generateModule('users', 'user', 'users', false, false),
},
})
ExperimentsLabs is going Rails !
The new version is going to be a Rails engine. A pre-release version
is already available if you want to test it.
A new Userstyle hightlighting GAFA links has been created from the Firefox addon Gafalink, by Baptiste Gelez, for users of other browsers
User style
Site update (v0.1.0)
- Updated this site to elabs 0.1.0
Site update(c31b499)
- Set up an album system to group files together
- Updated to CakePHP 3.3.9
- Various fixes