From 989787343dfc8d8f8ba7d84ede5c5a3a72baa4e9 Mon Sep 17 00:00:00 2001 From: Mark Cottman-Fields Date: Fri, 15 Jul 2016 22:39:38 +1000 Subject: [PATCH] Added licence, attribution, topic tags, and tag line to projects. See #278 and #289 --- app/controllers/projects_controller.rb | 4 +- app/models/project.rb | 58 +++++- app/models/site.rb | 3 + app/views/projects/_form.html.haml | 6 +- ...add_license_and_attribution_to_projects.rb | 6 + db/structure.sql | 187 +++++++----------- lib/modules/modify_notes.rb | 19 ++ spec/acceptance/audio_recordings_spec.rb | 2 +- spec/factories/project_factory.rb | 6 +- spec/factories/site_factory.rb | 2 +- spec/features/projects_spec.rb | 11 +- 11 files changed, 174 insertions(+), 130 deletions(-) create mode 100644 db/migrate/20160715100838_add_license_and_attribution_to_projects.rb create mode 100644 lib/modules/modify_notes.rb diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 89b1f4df..4a906638 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -85,7 +85,7 @@ def update do_authorize_instance respond_to do |format| - if @project.update_attributes(project_params) + if @project.update_custom_attrs(project_params) && @project.update_attributes(project_params) format.html { redirect_to @project, notice: 'Project was successfully updated.' } format.json { respond_show } else @@ -185,7 +185,7 @@ def filter private def project_params - params.require(:project).permit(:description, :image, :name, :notes, :urn) + params.require(:project).permit(:description, :image, :name, :notes, :urn, :tag_line, :topic_tags, :licence_spec, :attribution_cite) end def access_request_params diff --git a/app/models/project.rb b/app/models/project.rb index 0c6c5c38..81d780af 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2,6 +2,9 @@ class Project < ActiveRecord::Base # ensures that creator_id, updater_id, deleter_id are set include UserChange + # for updating notes field, which stores JSON + include ModifyNotes + # relationships belongs_to :creator, class_name: 'User', foreign_key: :creator_id, inverse_of: :created_projects belongs_to :updater, class_name: 'User', foreign_key: :updater_id, inverse_of: :updated_projects @@ -17,7 +20,29 @@ class Project < ActiveRecord::Base accepts_nested_attributes_for :permissions - #plugins + # store notes as json in a text column + serialize :notes, JSON + + # attributes that are not backed by db fields + attr_accessor :tag_line, :topic_tags + + def tag_line + if !self.notes.blank? && self.notes.include?('tag_line') + self.notes['tag_line'] + else + '' + end + end + + def topic_tags + if !self.notes.blank? && self.notes.include?('topic_tags') + self.notes['topic_tags'] + else + '' + end + end + + # plugins has_attached_file :image, styles: {span4: '300x300#', span3: '220x220#', span2: '140x140#', span1: '60x60#', spanhalf: '30x30#'}, default_url: '/images/project/project_:style.png' @@ -35,7 +60,7 @@ class Project < ActiveRecord::Base #validates :urn, uniqueness: {case_sensitive: false}, allow_blank: true, allow_nil: true validates_format_of :urn, with: /\Aurn:[a-z0-9][a-z0-9-]{0,31}:[a-z0-9()+,\-.:=@;$_!*'%\/?#]+\z/, message: 'urn %{value} is not valid, must be in format urn::', allow_blank: true, allow_nil: true validates_attachment_content_type :image, content_type: /\Aimage\/(jpg|jpeg|pjpeg|png|x-png|gif)\z/, message: 'file type %{value} is not allowed (only jpeg/png/gif images)' - + # make sure the project has a permission entry for the creator after it is created after_create :create_owner_permission @@ -43,11 +68,30 @@ def description_html CustomRender.render_markdown(self, :description) end + def update_custom_attrs(hash) + has_tag_line = hash.include?('tag_line') + content_tag_line = hash['tag_line'] + has_topic_tags = hash.include?('topic_tags') + content_topic_tags = hash['topic_tags'] + + if self.notes.blank? + self.notes = {} + end + + if has_tag_line + self.notes['tag_line'] = content_tag_line + end + if has_topic_tags + self.notes['topic_tags'] = content_topic_tags + end + true + end + # Define filter api settings def self.filter_settings { - valid_fields: [:id, :name, :description, :created_at, :creator_id], - render_fields: [:id, :name, :description, :creator_id], + valid_fields: [:id, :name, :description, :licence_spec, :attribution_cite, :created_at, :creator_id], + render_fields: [:id, :name, :description, :licence_spec, :attribution_cite, :creator_id], text_fields: [:name, :description], custom_fields: lambda { |item, user| @@ -57,9 +101,13 @@ def self.filter_settings project_hash = {} project_hash[:site_ids] = fresh_project.nil? ? nil : fresh_project.sites.pluck(:id).flatten - project_hash[:description_html]= fresh_project.description_html + unless fresh_project.notes.blank? + project_hash[:tag_line] = fresh_project.notes['tag_line'] if fresh_project.notes.include?('tag_line') + project_hash[:topic_tags]= fresh_project.notes['topic_tags'] if fresh_project.notes.include?('topic_tags') + end + [item, project_hash] }, controller: :projects, diff --git a/app/models/site.rb b/app/models/site.rb index 0e9edea0..60f11a09 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -29,6 +29,9 @@ class Site < ActiveRecord::Base acts_as_paranoid validates_as_paranoid + # store notes as json in a text column + serialize :notes, JSON + # association validations validates :creator, existence: true diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 50518289..2acd9f73 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -3,6 +3,10 @@ = field_set_tag do = f.error_notification = f.input :name, required: true, label: 'Project Name' - = f.input :description, input_html: {rows: '3'} + = f.input :tag_line, label: 'Project Tag Line', hint: 'Summarise your project in a few words' + = f.input :description, input_html: {rows: '4'} = render partial: 'shared/image_upload', locals: { f: f, model_instance: project, model_name: 'project' } + = f.input :topic_tags, label: 'Project Topics', hint: 'Enter descriptive labels, separated by commas' + = f.input :licence_spec, label: 'Project Licence', input_html: {rows: '5'}, placeholder: 'Enter the licence name, year, and copyright holder\'s name and a url to the licence.', hint: ('Need help choosing a licence? Try ' + link_to('Creative Commons', 'https://creativecommons.org/choose/') + ' or ' + link_to('ANDS', 'http://www.ands.org.au/working-with-data/enabling-data-reuse/licensing-for-reuse') + '.').html_safe + = f.input :attribution_cite, label: 'Attribution/Citation Suggestion', input_html: {rows: '5' }, placeholder: 'Enter the text you would like to be used when anyone refers to this project or the data it contains.' = f.button :submit_cancel, 'Submit', class: 'btn-default' \ No newline at end of file diff --git a/db/migrate/20160715100838_add_license_and_attribution_to_projects.rb b/db/migrate/20160715100838_add_license_and_attribution_to_projects.rb new file mode 100644 index 00000000..0ce0f62e --- /dev/null +++ b/db/migrate/20160715100838_add_license_and_attribution_to_projects.rb @@ -0,0 +1,6 @@ +class AddLicenseAndAttributionToProjects < ActiveRecord::Migration + def change + add_column :projects, :licence_spec, :text + add_column :projects, :attribution_cite, :text + end +end diff --git a/db/structure.sql b/db/structure.sql index fc858ae3..1c6350dc 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -35,16 +35,16 @@ SET default_with_oids = false; CREATE TABLE analysis_jobs ( id integer NOT NULL, - name character varying NOT NULL, - annotation_name character varying, + name character varying(255) NOT NULL, + annotation_name character varying(255), custom_settings text NOT NULL, script_id integer NOT NULL, creator_id integer NOT NULL, updater_id integer, deleter_id integer, deleted_at timestamp without time zone, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, description text, saved_search_id integer NOT NULL, started_at timestamp without time zone, @@ -121,7 +121,7 @@ CREATE TABLE audio_event_comments ( id integer NOT NULL, audio_event_id integer NOT NULL, comment text NOT NULL, - flag character varying, + flag character varying(255), flag_explain text, flagger_id integer, flagged_at timestamp without time zone, @@ -169,8 +169,8 @@ CREATE TABLE audio_events ( updater_id integer, deleter_id integer, deleted_at timestamp without time zone, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -201,10 +201,10 @@ CREATE TABLE audio_events_tags ( id integer NOT NULL, audio_event_id integer NOT NULL, tag_id integer NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, creator_id integer NOT NULL, - updater_id integer, - created_at timestamp without time zone, - updated_at timestamp without time zone + updater_id integer ); @@ -241,18 +241,18 @@ CREATE TABLE audio_recordings ( sample_rate_hertz integer, channels integer, bit_rate_bps integer, - media_type character varying NOT NULL, + media_type character varying(255) NOT NULL, data_length_bytes bigint NOT NULL, file_hash character varying(524) NOT NULL, - status character varying DEFAULT 'new'::character varying, + status character varying(255) DEFAULT 'new'::character varying, notes text, creator_id integer NOT NULL, updater_id integer, deleter_id integer, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, deleted_at timestamp without time zone, - original_file_name character varying, + original_file_name character varying(255), recorded_utc_offset character varying(20) ); @@ -284,13 +284,13 @@ CREATE TABLE bookmarks ( id integer NOT NULL, audio_recording_id integer, offset_seconds numeric(10,4), - name character varying, + name character varying(255), + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, creator_id integer NOT NULL, updater_id integer, - created_at timestamp without time zone, - updated_at timestamp without time zone, description text, - category character varying + category character varying(255) ); @@ -320,12 +320,12 @@ ALTER SEQUENCE bookmarks_id_seq OWNED BY bookmarks.id; CREATE TABLE permissions ( id integer NOT NULL, creator_id integer NOT NULL, - level character varying NOT NULL, + level character varying(255) NOT NULL, project_id integer NOT NULL, user_id integer, updater_id integer, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, allow_logged_in boolean DEFAULT false NOT NULL, allow_anonymous boolean DEFAULT false NOT NULL, CONSTRAINT permissions_exclusive_cols CHECK ((((((user_id IS NOT NULL) AND (NOT allow_logged_in)) AND (NOT allow_anonymous)) OR (((user_id IS NULL) AND allow_logged_in) AND (NOT allow_anonymous))) OR (((user_id IS NULL) AND (NOT allow_logged_in)) AND allow_anonymous))) @@ -357,20 +357,22 @@ ALTER SEQUENCE permissions_id_seq OWNED BY permissions.id; CREATE TABLE projects ( id integer NOT NULL, - name character varying NOT NULL, + name character varying(255) NOT NULL, description text, - urn character varying, + urn character varying(255), notes text, creator_id integer NOT NULL, updater_id integer, deleter_id integer, deleted_at timestamp without time zone, - image_file_name character varying, - image_content_type character varying, + image_file_name character varying(255), + image_content_type character varying(255), image_file_size integer, image_updated_at timestamp without time zone, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + licence_spec text, + attribution_cite text ); @@ -453,7 +455,7 @@ ALTER SEQUENCE saved_searches_id_seq OWNED BY saved_searches.id; -- CREATE TABLE schema_migrations ( - version character varying NOT NULL + version character varying(255) NOT NULL ); @@ -463,9 +465,9 @@ CREATE TABLE schema_migrations ( CREATE TABLE scripts ( id integer NOT NULL, - name character varying NOT NULL, - description character varying, - analysis_identifier character varying NOT NULL, + name character varying(255) NOT NULL, + description character varying(255), + analysis_identifier character varying(255) NOT NULL, version numeric(4,2) DEFAULT 0.1 NOT NULL, verified boolean DEFAULT false, group_id integer, @@ -502,7 +504,7 @@ ALTER SEQUENCE scripts_id_seq OWNED BY scripts.id; CREATE TABLE sites ( id integer NOT NULL, - name character varying NOT NULL, + name character varying(255) NOT NULL, longitude numeric(9,6), latitude numeric(9,6), notes text, @@ -510,12 +512,12 @@ CREATE TABLE sites ( updater_id integer, deleter_id integer, deleted_at timestamp without time zone, - image_file_name character varying, - image_content_type character varying, + image_file_name character varying(255), + image_content_type character varying(255), image_file_size integer, image_updated_at timestamp without time zone, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, description text, tzinfo_tz character varying(255), rails_tz character varying(255) @@ -579,15 +581,15 @@ ALTER SEQUENCE tag_groups_id_seq OWNED BY tag_groups.id; CREATE TABLE tags ( id integer NOT NULL, - text character varying NOT NULL, + text character varying(255) NOT NULL, is_taxanomic boolean DEFAULT false NOT NULL, - type_of_tag character varying DEFAULT 'general'::character varying NOT NULL, + type_of_tag character varying(255) DEFAULT 'general'::character varying NOT NULL, retired boolean DEFAULT false NOT NULL, notes text, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, creator_id integer NOT NULL, - updater_id integer, - created_at timestamp without time zone, - updated_at timestamp without time zone + updater_id integer ); @@ -616,31 +618,31 @@ ALTER SEQUENCE tags_id_seq OWNED BY tags.id; CREATE TABLE users ( id integer NOT NULL, - email character varying NOT NULL, - user_name character varying NOT NULL, - encrypted_password character varying NOT NULL, - reset_password_token character varying, + email character varying(255) DEFAULT NULL::character varying NOT NULL, + user_name character varying(255) DEFAULT NULL::character varying NOT NULL, + encrypted_password character varying(255) DEFAULT NULL::character varying NOT NULL, + reset_password_token character varying(255), reset_password_sent_at timestamp without time zone, remember_created_at timestamp without time zone, sign_in_count integer DEFAULT 0, current_sign_in_at timestamp without time zone, last_sign_in_at timestamp without time zone, - current_sign_in_ip character varying, - last_sign_in_ip character varying, - confirmation_token character varying, + current_sign_in_ip character varying(255), + last_sign_in_ip character varying(255), + confirmation_token character varying(255), confirmed_at timestamp without time zone, confirmation_sent_at timestamp without time zone, - unconfirmed_email character varying, + unconfirmed_email character varying(255), failed_attempts integer DEFAULT 0, - unlock_token character varying, + unlock_token character varying(255), locked_at timestamp without time zone, - authentication_token character varying, - invitation_token character varying, - created_at timestamp without time zone, - updated_at timestamp without time zone, + authentication_token character varying(255), + invitation_token character varying(255), + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, roles_mask integer, - image_file_name character varying, - image_content_type character varying, + image_file_name character varying(255), + image_content_type character varying(255), image_file_size integer, image_updated_at timestamp without time zone, preferences text, @@ -894,13 +896,6 @@ ALTER TABLE ONLY users ADD CONSTRAINT users_pkey PRIMARY KEY (id); --- --- Name: analysis_jobs_name_uidx; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE UNIQUE INDEX analysis_jobs_name_uidx ON analysis_jobs USING btree (name, creator_id); - - -- -- Name: audio_recordings_created_updated_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -978,13 +973,6 @@ CREATE INDEX index_analysis_jobs_on_creator_id ON analysis_jobs USING btree (cre CREATE INDEX index_analysis_jobs_on_deleter_id ON analysis_jobs USING btree (deleter_id); --- --- Name: index_analysis_jobs_on_saved_search_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_analysis_jobs_on_saved_search_id ON analysis_jobs USING btree (saved_search_id); - - -- -- Name: index_analysis_jobs_on_script_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -1188,27 +1176,6 @@ CREATE INDEX index_projects_on_deleter_id ON projects USING btree (deleter_id); CREATE INDEX index_projects_on_updater_id ON projects USING btree (updater_id); --- --- Name: index_projects_saved_searches_on_project_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_projects_saved_searches_on_project_id ON projects_saved_searches USING btree (project_id); - - --- --- Name: index_projects_saved_searches_on_project_id_and_saved_search_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_projects_saved_searches_on_project_id_and_saved_search_id ON projects_saved_searches USING btree (project_id, saved_search_id); - - --- --- Name: index_projects_saved_searches_on_saved_search_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_projects_saved_searches_on_saved_search_id ON projects_saved_searches USING btree (saved_search_id); - - -- -- Name: index_projects_sites_on_project_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -1230,20 +1197,6 @@ CREATE INDEX index_projects_sites_on_project_id_and_site_id ON projects_sites US CREATE INDEX index_projects_sites_on_site_id ON projects_sites USING btree (site_id); --- --- Name: index_saved_searches_on_creator_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_saved_searches_on_creator_id ON saved_searches USING btree (creator_id); - - --- --- Name: index_saved_searches_on_deleter_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_saved_searches_on_deleter_id ON saved_searches USING btree (deleter_id); - - -- -- Name: index_scripts_on_creator_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -1321,18 +1274,25 @@ CREATE UNIQUE INDEX index_users_on_confirmation_token ON users USING btree (conf CREATE UNIQUE INDEX index_users_on_email ON users USING btree (email); +-- +-- Name: jobs_name_uidx; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE UNIQUE INDEX jobs_name_uidx ON analysis_jobs USING btree (name); + + -- -- Name: permissions_project_allow_anonymous_uidx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- -CREATE UNIQUE INDEX permissions_project_allow_anonymous_uidx ON permissions USING btree (project_id, allow_anonymous) WHERE (allow_anonymous IS TRUE); +CREATE UNIQUE INDEX permissions_project_allow_anonymous_uidx ON permissions USING btree (project_id, allow_anonymous) WHERE allow_anonymous; -- -- Name: permissions_project_allow_logged_in_uidx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- -CREATE UNIQUE INDEX permissions_project_allow_logged_in_uidx ON permissions USING btree (project_id, allow_logged_in) WHERE (allow_logged_in IS TRUE); +CREATE UNIQUE INDEX permissions_project_allow_logged_in_uidx ON permissions USING btree (project_id, allow_logged_in) WHERE allow_logged_in; -- @@ -1356,13 +1316,6 @@ CREATE UNIQUE INDEX projects_name_uidx ON projects USING btree (name); CREATE UNIQUE INDEX queue_id_uidx ON analysis_jobs_items USING btree (queue_id); --- --- Name: saved_searches_name_creator_id_uidx; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE UNIQUE INDEX saved_searches_name_creator_id_uidx ON saved_searches USING btree (name, creator_id); - - -- -- Name: tag_groups_uidx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -1869,6 +1822,8 @@ INSERT INTO schema_migrations (version) VALUES ('20150904234334'); INSERT INTO schema_migrations (version) VALUES ('20150905234917'); +INSERT INTO schema_migrations (version) VALUES ('20151003042515'); + INSERT INTO schema_migrations (version) VALUES ('20160226103516'); INSERT INTO schema_migrations (version) VALUES ('20160226130353'); @@ -1877,3 +1832,5 @@ INSERT INTO schema_migrations (version) VALUES ('20160306083845'); INSERT INTO schema_migrations (version) VALUES ('20160420030414'); +INSERT INTO schema_migrations (version) VALUES ('20160715100838'); + diff --git a/lib/modules/modify_notes.rb b/lib/modules/modify_notes.rb new file mode 100644 index 00000000..fbb48ba1 --- /dev/null +++ b/lib/modules/modify_notes.rb @@ -0,0 +1,19 @@ +module ModifyNotes + private + + def get_hash_value(hash, key) + key_s = key.to_s + if hash.blank? + '' + elsif hash.include?(key_s) + hash[key_s] + end + end + + def set_hash_value(hash, key, value) + key_s = key.to_s + hash = {} if hash.blank? + hash[key_s] = value + hash + end +end \ No newline at end of file diff --git a/spec/acceptance/audio_recordings_spec.rb b/spec/acceptance/audio_recordings_spec.rb index 627ec755..2b05a8fc 100644 --- a/spec/acceptance/audio_recordings_spec.rb +++ b/spec/acceptance/audio_recordings_spec.rb @@ -1179,7 +1179,7 @@ def test_overlap }.to_json } let(:authentication_token) { reader_token } standard_request_options(:post, 'FILTER (as reader filtering by project image_file_name)', :bad_request, { - response_body_content: 'Filter parameters were not valid: Name must be in [:id, :name, :description, :created_at, :creator_id], got image_file_name' + response_body_content: 'Filter parameters were not valid: Name must be in [:id, :name, :description, :licence_spec, :attribution_cite, :created_at, :creator_id], got image_file_name' }) end diff --git a/spec/factories/project_factory.rb b/spec/factories/project_factory.rb index bdfc4059..6e68e781 100644 --- a/spec/factories/project_factory.rb +++ b/spec/factories/project_factory.rb @@ -4,7 +4,7 @@ sequence(:name) { |n| "gen_project#{n}" } sequence(:description) { |n| "project description #{n}" } sequence(:urn) { |n| "urn:project:example.org/project/#{n}" } - sequence(:notes) { |n| "note number #{n}" } + #sequence(:notes) { |n| {'a note': "note number #{n}"} } creator @@ -17,7 +17,7 @@ site_count 1 end after(:create) do |project, evaluator| - raise 'Creator was blank' if evaluator.creator.blank? + raise 'Creator was blank' if evaluator.creator.blank? evaluator.site_count.times do project.sites << FactoryGirl.create(:site_with_audio_recordings, creator: evaluator.creator) end @@ -29,7 +29,7 @@ saved_search_count 1 end after(:create) do |project, evaluator| - raise 'Creator was blank' if evaluator.creator.blank? + raise 'Creator was blank' if evaluator.creator.blank? evaluator.saved_search_count.times do project.saved_searches << FactoryGirl.create(:saved_search_with_analysis_jobs, creator: evaluator.creator) end diff --git a/spec/factories/site_factory.rb b/spec/factories/site_factory.rb index c7ae82ae..7a8c9443 100644 --- a/spec/factories/site_factory.rb +++ b/spec/factories/site_factory.rb @@ -2,7 +2,7 @@ factory :site do sequence(:name) { |n| "site name #{n}" } - sequence(:notes) { |n| "note number #{n}" } + #sequence(:notes) { |n| {'a note': "note number #{n}"} } sequence(:description) { |n| "site description #{n}" } creator diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 199598ae..005b7670 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -92,11 +92,16 @@ def select_by_value(id, value) it 'updates project when filling out form correctly' do visit edit_project_path(project) #save_and_open_page - fill_in 'project[name]', with: 'test name' + fill_in 'project[name]', with: 'test name 123' + fill_in 'project[tag_line]', with: 'just a tag line, saying hi' fill_in 'project[description]', with: 'description' attach_file('project[image]', 'public/images/user/user-512.png') + fill_in 'project[topic_tags]', with: 'topic 1, topic 2, topic 3' + fill_in 'project[licence_spec]', with: 'I have a licence to trill!' + fill_in 'project[attribution_cite]', with: 'By me, of course' click_button 'Submit' - expect(page).to have_content('test name') + expect(page).to have_content('Project was successfully updated.') + expect(page).to have_content('test name 123') end end @@ -340,6 +345,7 @@ def select_by_value(id, value) fill_in 'project[description]', with: 'description' attach_file('project[image]', 'public/images/user/user-512.png') click_button 'Submit' + expect(page).to have_content('Project was successfully updated.') expect(page).to have_content('test name') end @@ -388,6 +394,7 @@ def select_by_value(id, value) fill_in 'project[description]', with: 'description' attach_file('project[image]', 'public/images/user/user-512.png') click_button 'Submit' + expect(page).to have_content('Project was successfully updated.') expect(page).to have_content('test name') end