-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathplans_spec.rb
More file actions
57 lines (49 loc) · 2.02 KB
/
plans_spec.rb
File metadata and controls
57 lines (49 loc) · 2.02 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Plans', type: :feature do
include Webmocks
before do
@default_template = create(:template, :default, :published)
@org = create(:org)
@research_org = create(:org, :organisation, :research_institute,
name: 'Test Research Org', templates: 1)
@funding_org = create(:org, :funder, name: 'Test Funder Org', templates: 1)
@template = create(:template, org: @org)
@user = create(:user, org: @org)
sign_in(@user)
stub_openaire
# OpenURI.expects(:open_uri).returns(<<~XML
# <form-value-pairs>
# <value-pairs value-pairs-name="H2020projects" dc-term="relation">
# <pair>
# <displayed-value>
# 115797 - INNODIA - Translational approaches to disease modifying therapy of ...
# </displayed-value>
# <stored-value>info:eu-repo/grantAgreement/EC/H2020/115797/EU</stored-value>
# </pair>
# </value-pairs>
# </form-value-pairs>
# XML
# )
end
it 'User creates a new Plan', :js do
# TODO: Revisit this after we start refactoring/building out or tests for
# the new create plan workflow. For some reason the plans/new.js isn't
# firing here but works fine in the UI with manual testing
# Action
click_link 'Create plan'
fill_in :plan_title, with: 'My test plan'
choose_suggestion('plan_org_org_name', @research_org)
choose_suggestion('plan_funder_org_name', @funding_org)
click_button 'Create plan'
# Expectations
expect(page).to have_content('Successfully created the plan.')
expect(@user.plans).to be_one
@plan = Plan.last
expect(current_path).to eql(plan_path(@plan))
expect(page).to have_css("input[type=text][value='#{@plan.title}']")
expect(@plan.title).to eql('My test plan')
expect(@plan.org_id).to eql(@research_org.id)
expect(@plan.funder_id).to eql(@funding_org.id)
end
end