| ... | @@ -35,10 +35,18 @@ describe "/objects/index", type: :view do |
... | @@ -35,10 +35,18 @@ describe "/objects/index", type: :view do |
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
let(:objects) do
|
|
let(:objects) do
|
|
|
assign :objects, build_paginated_collection(:object, ObjectDecorator, parent: parent, context: context)
|
|
assign(
|
|
|
|
:objects,
|
|
|
|
build_paginated_collection(
|
|
|
|
:object,
|
|
|
|
ObjectDecorator,
|
|
|
|
parent: parent,
|
|
|
|
context: context
|
|
|
|
)
|
|
|
|
)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
before :each do
|
|
before(:each) do
|
|
|
allow(view).to receive(:collection).and_return(objects)
|
|
allow(view).to receive(:collection).and_return(objects)
|
|
|
allow(view).to receive(:current_referential).and_return(parent)
|
|
allow(view).to receive(:current_referential).and_return(parent)
|
|
|
controller.request.path_parameters[:parent_id] = parent.id
|
|
controller.request.path_parameters[:parent_id] = parent.id
|
| ... | @@ -46,9 +54,27 @@ describe "/objects/index", type: :view do |
... | @@ -46,9 +54,27 @@ describe "/objects/index", type: :view do |
|
|
end
|
|
end
|
|
|
|
|
|
|
|
common_items = ->{
|
|
common_items = ->{
|
|
|
it { should have_link_for_each_item(objects, "show", -> (object){ view.parent_object_path(parent, object) }) }
|
|
it do
|
|
|
it { should have_link_for_each_item(objects, "foo", -> (object){ view.parent_foo_path(parent, object.foo) }) }
|
|
should have_link_for_each_item(
|
|
|
it { should have_link_for_each_item(objects, "bar", -> (object){ view.parent_bar_path(parent, object.bar) }) }
|
|
objects,
|
|
|
|
"show",
|
|
|
|
->(object) { view.parent_object_path(parent, object) }
|
|
|
|
)
|
|
|
|
end
|
|
|
|
it do
|
|
|
|
should have_link_for_each_item(
|
|
|
|
objects,
|
|
|
|
"foo",
|
|
|
|
->(object) { view.parent_foo_path(parent, object.foo) }
|
|
|
|
)
|
|
|
|
end
|
|
|
|
it do
|
|
|
|
should have_link_for_each_item(
|
|
|
|
objects,
|
|
|
|
"bar",
|
|
|
|
->(object) { view.parent_bar_path(parent, object.bar) }
|
|
|
|
)
|
|
|
|
end
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
common_items.call()
|
|
common_items.call()
|
| ... | @@ -56,7 +82,15 @@ describe "/objects/index", type: :view do |
... | @@ -56,7 +82,15 @@ describe "/objects/index", type: :view do |
|
|
|
|
|
|
|
with_permission "objects.activate" do
|
|
with_permission "objects.activate" do
|
|
|
common_items.call()
|
|
common_items.call()
|
|
|
it { should have_link_for_each_item(objects, "activate", -> (object){ view.activate_parent_object_path(parent, object) }) }
|
|
|
|
|
|
it do
|
|
|
|
should have_link_for_each_item(
|
|
|
|
objects,
|
|
|
|
"activate",
|
|
|
|
->(object) { view.activate_parent_object_path(parent, object) }
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
it { should have_the_right_number_of_links(objects, 4) }
|
|
it { should have_the_right_number_of_links(objects, 4) }
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
| ... | @@ -82,7 +116,7 @@ RSpec.describe ObjectController, type: :controller do |
... | @@ -82,7 +116,7 @@ RSpec.describe ObjectController, type: :controller do |
|
|
let(:request){ put :deactivate, id: object.id, parent_id: parent.id }
|
|
let(:request){ put :deactivate, id: object.id, parent_id: parent.id }
|
|
|
|
|
|
|
|
it 'should redirect to 403' do
|
|
it 'should redirect to 403' do
|
|
|
expect(request).to redirect_to "/403"
|
|
expect(request).to redirect_to "/403"
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
with_permission "foo.bar" do
|
|
with_permission "foo.bar" do
|
| ... | @@ -95,11 +129,13 @@ RSpec.describe ObjectController, type: :controller do |
... | @@ -95,11 +129,13 @@ RSpec.describe ObjectController, type: :controller do |
|
|
|
|
|
|
|
describe 'PUT activate' do
|
|
describe 'PUT activate' do
|
|
|
let(:request){ put :activate, id: object.id, parent_id: parent.id }
|
|
let(:request){ put :activate, id: object.id, parent_id: parent.id }
|
|
|
before(:each){
|
|
|
|
|
|
before(:each) do
|
|
|
object.deactivate!
|
|
object.deactivate!
|
|
|
}
|
|
end
|
|
|
|
|
|
|
it 'should redirect to 403' do
|
|
it 'should redirect to 403' do
|
|
|
expect(request).to redirect_to "/403"
|
|
expect(request).to redirect_to "/403"
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
with_permission "objects.change_status" do
|
|
with_permission "objects.change_status" do
|
| ... | | ... | |