|
55 | 55 | end |
56 | 56 | end |
57 | 57 |
|
| 58 | + context "when accessing a distribution from another organization" do |
| 59 | + it "returns 404" do |
| 60 | + other_distribution = create(:distribution, organization: create(:organization)) |
| 61 | + get print_distribution_path(id: other_distribution.id) |
| 62 | + expect(response.status).to eq(404) |
| 63 | + end |
| 64 | + end |
| 65 | + |
58 | 66 | include_examples "restricts access to organization users/admins" |
59 | 67 | end |
60 | 68 |
|
|
530 | 538 | end |
531 | 539 | end |
532 | 540 |
|
| 541 | + context "when accessing a distribution from another organization" do |
| 542 | + it "returns 404" do |
| 543 | + other_distribution = create(:distribution, organization: create(:organization)) |
| 544 | + get distribution_path(id: other_distribution.id) |
| 545 | + expect(response.status).to eq(404) |
| 546 | + end |
| 547 | + end |
| 548 | + |
533 | 549 | include_examples "restricts access to organization users/admins" |
534 | 550 | end |
535 | 551 |
|
|
727 | 743 | end |
728 | 744 | end |
729 | 745 |
|
| 746 | + context "when accessing a distribution from another organization" do |
| 747 | + it "returns 404" do |
| 748 | + other_distribution = create(:distribution, organization: create(:organization)) |
| 749 | + original_comment = other_distribution.comment |
| 750 | + patch distribution_path(id: other_distribution.id), params: {distribution: {comment: "hacked"}} |
| 751 | + expect(response.status).to eq(404) |
| 752 | + expect(other_distribution.reload.comment).to eq(original_comment) |
| 753 | + end |
| 754 | + end |
| 755 | + |
730 | 756 | include_examples "restricts access to organization users/admins" |
731 | 757 | end |
732 | 758 |
|
|
947 | 973 | end |
948 | 974 | end |
949 | 975 |
|
| 976 | + context "when accessing a distribution from another organization" do |
| 977 | + it "returns 404" do |
| 978 | + other_distribution = create(:distribution, organization: create(:organization)) |
| 979 | + get edit_distribution_path(id: other_distribution.id) |
| 980 | + expect(response.status).to eq(404) |
| 981 | + end |
| 982 | + end |
| 983 | + |
950 | 984 | include_examples "restricts access to organization users/admins" |
951 | 985 | end |
952 | 986 |
|
|
984 | 1018 | expect(flash[:error]).to eq("We can't delete distributions entered before #{1.day.ago.to_date}.") |
985 | 1019 | end |
986 | 1020 |
|
| 1021 | + context "when accessing a distribution from another organization" do |
| 1022 | + it "returns 404" do |
| 1023 | + other_distribution = create(:distribution, organization: create(:organization)) |
| 1024 | + expect { |
| 1025 | + delete distribution_path(id: other_distribution.id) |
| 1026 | + }.not_to change { Distribution.count } |
| 1027 | + expect(response.status).to eq(404) |
| 1028 | + end |
| 1029 | + end |
| 1030 | + |
987 | 1031 | include_examples "restricts access to organization users/admins" |
988 | 1032 | end |
989 | 1033 | end |
|
0 commit comments