|
1 | 1 | require 'rails_helper' |
2 | 2 |
|
3 | 3 | RSpec.describe ExperimentsController, type: :controller do |
| 4 | + include BasicAuthHelper |
4 | 5 | describe "GET conduct" do |
5 | 6 | it "Raises controlled error on wrong experiment" do |
6 | 7 | @experiment = create(:experiment_with_static_text) |
7 | 8 | get 'conduct', :params => {:id_hash => @experiment.id_hash} ## this is the wrong type of hash |
8 | 9 | expect(response).to have_http_status(:error) |
9 | 10 | end |
10 | 11 | end |
| 12 | + |
| 13 | + describe "GET edit" do |
| 14 | + it "opens edit page" do |
| 15 | + login_as_admin |
| 16 | + @experiment = create(:experiment_with_static_text) |
| 17 | + get 'edit', :params => {:id => @experiment.id} ## this is the wrong type of hash |
| 18 | + expect(response).to have_http_status(:ok) |
| 19 | + end |
| 20 | + end |
| 21 | + |
| 22 | + |
| 23 | + describe "POST update" do |
| 24 | + it "can update the title" do |
| 25 | + login_as_admin |
| 26 | + @experiment = create(:experiment_with_static_text) |
| 27 | + new_title = Faker::Name.name |
| 28 | + patch 'update', :params => {:id => @experiment.id, :experiment => {:title => new_title}} ## this is the wrong type of hash |
| 29 | + expect(response).to have_http_status(:found) |
| 30 | + @experiment.reload |
| 31 | + expect(@experiment.title).to eq(new_title) |
| 32 | + |
| 33 | + end |
| 34 | + end |
| 35 | + |
| 36 | + |
| 37 | + describe "DELETE destroy" do |
| 38 | + it "can update the title" do |
| 39 | + login_as_admin |
| 40 | + @experiment = create(:experiment_with_static_text) |
| 41 | + experiment_id = @experiment.id |
| 42 | + expect(Experiment.where(:id => experiment_id).length).to eq(1) |
| 43 | + |
| 44 | + new_title = Faker::Name.name |
| 45 | + delete 'destroy', :params => {:id => @experiment.id} ## this is the wrong type of hash |
| 46 | + expect(response).to have_http_status(:found) |
| 47 | + expect(Experiment.where(:id => experiment_id).length).to eq(0) |
| 48 | + |
| 49 | + end |
| 50 | + end |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
11 | 57 | end |
0 commit comments