generated from dxw/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
users_can_edit_a_matched_effort_spec.rb
44 lines (31 loc) · 1.63 KB
/
users_can_edit_a_matched_effort_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
RSpec.describe "Users can create a matched effort" do
context "when signed in as a partner organisation user" do
let(:user) { create(:partner_organisation_user) }
let(:programme) { create(:programme_activity, extending_organisation: user.organisation) }
let!(:project) { create(:project_activity, :with_report, organisation: user.organisation, parent: programme) }
let!(:matched_effort_provider) { create(:matched_effort_provider) }
let!(:matched_effort) { create(:matched_effort, activity: project) }
before { authenticate!(user: user) }
before do
visit organisation_activity_path(project.organisation, project)
click_on "Other funding"
find("a[href='#{edit_activity_matched_effort_path(project, matched_effort)}']").click
end
after { logout }
scenario "they can edit a matched effort" do
matched_effort.organisation = matched_effort_provider
matched_effort.notes = "Here are some new notes"
fill_in_matched_effort_form(matched_effort)
expect(page).to have_content(t("action.matched_effort.update.success"))
expect(matched_effort.reload.organisation).to eq(matched_effort_provider)
expect(matched_effort.notes).to eq("Here are some new notes")
end
scenario "they see a sumamry and the errors when a required field is missing" do
select("", from: "matched_effort[organisation_id]")
click_on t("default.button.submit")
expect(page).to_not have_content(t("action.matched_effort.update.success"))
expect(page).to have_selector(".govuk-error-summary")
expect(page).to have_content("Organisation can't be blank")
end
end
end