aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/lines_controller_spec.rb
diff options
context:
space:
mode:
authorZog2017-12-20 12:58:20 +0100
committerAlban Peignier2017-12-21 21:19:27 +0100
commit9a34cb48f49df574ae1e7c599713ed246e2938cf (patch)
tree49c91cfdaa645f39363c3e8c492b86a0dde08c89 /spec/controllers/lines_controller_spec.rb
parent8cd9b9ee5fc127b2f39a9c89c71327ab8d5e9cec (diff)
downloadchouette-core-9a34cb48f49df574ae1e7c599713ed246e2938cf.tar.bz2
Refs #5430 @2h; Deactivate lines instead of destroying them
- Add `activate` and `deactivate` actions in `LinesController`, as well as corresponding routes - Add `activate!` and `deactivate!` methods in `Chouette::Line`, as well as `activated?` - Add `activate?` and `deactivate?` permissions in `LinePolicy` - Add corresponding `action_links`in the Decorator - Create helper for these actions - Add an optional `'extra_class` to the Links - Update styles for ".delete-action" to handle the case where there are several - Add I18n keys accordingly
Diffstat (limited to 'spec/controllers/lines_controller_spec.rb')
-rw-r--r--spec/controllers/lines_controller_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/controllers/lines_controller_spec.rb b/spec/controllers/lines_controller_spec.rb
new file mode 100644
index 000000000..ce5adbbdd
--- /dev/null
+++ b/spec/controllers/lines_controller_spec.rb
@@ -0,0 +1,38 @@
+RSpec.describe LinesController, :type => :controller do
+ login_user
+
+ let(:line_referential) { create :line_referential }
+ let(:line) { create :line, line_referential: line_referential }
+
+ describe 'PUT deactivate' do
+ let(:request){ put :deactivate, id: line.id, line_referential_id: line_referential.id }
+
+ it 'should redirect to 403' do
+ expect(request).to redirect_to "/403"
+ end
+
+ with_permission "lines.change_status" do
+ it 'returns HTTP success' do
+ expect(request).to redirect_to [line_referential, line]
+ expect(line.reload).to be_deactivated
+ end
+ end
+ end
+
+ describe 'PUT activate' do
+ let(:request){ put :activate, id: line.id, line_referential_id: line_referential.id }
+ before(:each){
+ line.deactivate!
+ }
+ it 'should redirect to 403' do
+ expect(request).to redirect_to "/403"
+ end
+
+ with_permission "lines.change_status" do
+ it 'returns HTTP success' do
+ expect(request).to redirect_to [line_referential, line]
+ expect(line.reload).to be_activated
+ end
+ end
+ end
+end