diff --git a/app/models/project.rb b/app/models/project.rb index f205429..793a6c2 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -3,11 +3,6 @@ extend FriendlyId - attr_accessible :dmptemplate_id, :title, :organisation_id, :unit_id, :guidance_group_ids, - :project_group_ids, :funder_id, :institution_id, :grant_number, :identifier, - :description, :principal_investigator, :principal_investigator_identifier, - :data_contact, :funder_name, :as => [:default, :admin] - #associations between tables belongs_to :dmptemplate belongs_to :organisation @@ -16,6 +11,20 @@ has_and_belongs_to_many :guidance_groups, join_table: "project_guidance" friendly_id :title, use: [:slugged, :history, :finders] + + # Set the is_public flag to false if we are making this a test plan + # ----------------------------------------------------------------- + def is_test=(val) + self[:is_public] = false if val && is_public? + self[:is_test] = val + end + + # Set the is_test flag to false if we are making this plan public + # ----------------------------------------------------------------- + def is_public=(val) + self[:is_test] = false if val && is_test? + self[:is_public] = val + end ## # returns the title of the project diff --git a/db/migrate/20170103171414_add_test_and_public_to_projects.rb b/db/migrate/20170103171414_add_test_and_public_to_projects.rb new file mode 100644 index 0000000..e62cc69 --- /dev/null +++ b/db/migrate/20170103171414_add_test_and_public_to_projects.rb @@ -0,0 +1,6 @@ +class AddTestAndPublicToProjects < ActiveRecord::Migration + def change + add_column :projects, :is_test, :boolean, default: false + add_column :projects, :is_public, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 671fdb9..b40c240 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,446 +11,452 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20161102221313) do +ActiveRecord::Schema.define(version: 20170103171414) do create_table "answers", force: :cascade do |t| - t.text "text" - t.integer "plan_id" - t.integer "user_id" - t.integer "question_id" - t.datetime "created_at" - t.datetime "updated_at" + t.text "text", limit: 65535 + t.integer "plan_id", limit: 4 + t.integer "user_id", limit: 4 + t.integer "question_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "answers_options", id: false, force: :cascade do |t| - t.integer "answer_id", null: false - t.integer "option_id", null: false + t.integer "answer_id", limit: 4, null: false + t.integer "option_id", limit: 4, null: false end - add_index "answers_options", ["answer_id", "option_id"], name: "index_answers_options_on_answer_id_and_option_id" + add_index "answers_options", ["answer_id", "option_id"], name: "index_answers_options_on_answer_id_and_option_id", using: :btree create_table "comments", force: :cascade do |t| - t.integer "user_id" - t.integer "question_id" - t.text "text" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "user_id", limit: 4 + t.integer "question_id", limit: 4 + t.text "text", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "archived" - t.integer "plan_id" - t.integer "archived_by" + t.integer "plan_id", limit: 4 + t.integer "archived_by", limit: 4 end create_table "dmptemplates", force: :cascade do |t| - t.string "title" - t.text "description" + t.string "title", limit: 255 + t.text "description", limit: 65535 t.boolean "published" - t.integer "user_id" - t.integer "organisation_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "locale" + t.integer "user_id", limit: 4 + t.integer "organisation_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "locale", limit: 255 t.boolean "is_default" end create_table "dmptemplates_guidance_groups", id: false, force: :cascade do |t| - t.integer "dmptemplate_id" - t.integer "guidance_group_id" + t.integer "dmptemplate_id", limit: 4 + t.integer "guidance_group_id", limit: 4 end create_table "exported_plans", force: :cascade do |t| - t.integer "plan_id" - t.integer "user_id" - t.string "format" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "plan_id", limit: 4 + t.integer "user_id", limit: 4 + t.string "format", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "file_types", force: :cascade do |t| - t.string "name" - t.string "icon_name" - t.integer "icon_size" - t.string "icon_location" - t.datetime "created_at" - t.datetime "updated_at" + t.string "name", limit: 255 + t.string "icon_name", limit: 255 + t.integer "icon_size", limit: 4 + t.string "icon_location", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "file_uploads", force: :cascade do |t| - t.string "name" - t.string "title" - t.text "description" - t.integer "size" + t.string "name", limit: 255 + t.string "title", limit: 255 + t.text "description", limit: 65535 + t.integer "size", limit: 4 t.boolean "published" - t.string "location" - t.integer "file_type_id" - t.datetime "created_at" - t.datetime "updated_at" + t.string "location", limit: 255 + t.integer "file_type_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "friendly_id_slugs", force: :cascade do |t| - t.string "slug", null: false - t.integer "sluggable_id", null: false + t.string "slug", limit: 255, null: false + t.integer "sluggable_id", limit: 4, null: false t.string "sluggable_type", limit: 40 t.datetime "created_at" end - add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type", unique: true - add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id" - add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type" + add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type", unique: true, using: :btree + add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id", using: :btree + add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type", using: :btree create_table "guidance_groups", force: :cascade do |t| - t.string "name" - t.integer "organisation_id" - t.datetime "created_at" - t.datetime "updated_at" + t.string "name", limit: 255 + t.integer "organisation_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "optional_subset" t.boolean "published" end create_table "guidance_in_group", id: false, force: :cascade do |t| - t.integer "guidance_id", null: false - t.integer "guidance_group_id", null: false + t.integer "guidance_id", limit: 4, null: false + t.integer "guidance_group_id", limit: 4, null: false end - add_index "guidance_in_group", ["guidance_id", "guidance_group_id"], name: "index_guidance_in_group_on_guidance_id_and_guidance_group_id" + add_index "guidance_in_group", ["guidance_id", "guidance_group_id"], name: "index_guidance_in_group_on_guidance_id_and_guidance_group_id", using: :btree create_table "guidances", force: :cascade do |t| - t.text "text" - t.integer "guidance_group_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "question_id" + t.text "text", limit: 65535 + t.integer "guidance_group_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "question_id", limit: 4 t.boolean "published" end create_table "identifier_schemes", force: :cascade do |t| - t.string "name" - t.string "description" + t.string "name", limit: 255 + t.string "description", limit: 255 t.boolean "active" t.datetime "created_at" t.datetime "updated_at" + t.boolean "use_for_login", default: false end create_table "languages", force: :cascade do |t| - t.string "abbreviation" - t.string "description" - t.string "name" + t.string "abbreviation", limit: 255 + t.string "description", limit: 255 + t.string "name", limit: 255 t.boolean "default_language" end create_table "option_warnings", force: :cascade do |t| - t.integer "organisation_id" - t.integer "option_id" - t.text "text" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "organisation_id", limit: 4 + t.integer "option_id", limit: 4 + t.text "text", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "options", force: :cascade do |t| - t.integer "question_id" - t.string "text" - t.integer "number" + t.integer "question_id", limit: 4 + t.string "text", limit: 255 + t.integer "number", limit: 4 t.boolean "is_default" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "org_token_permissions", force: :cascade do |t| - t.integer "organisation_id" - t.integer "token_permission_type_id" + t.integer "organisation_id", limit: 4 + t.integer "token_permission_type_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" end create_table "organisation_types", force: :cascade do |t| - t.string "name" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" + t.string "name", limit: 255 + t.text "description", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "organisations", force: :cascade do |t| - t.string "name" - t.string "abbreviation" - t.string "target_url" - t.integer "organisation_type_id" - t.string "domain" - t.string "wayfless_entity" - t.integer "stylesheet_file_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "parent_id" + t.string "name", limit: 255 + t.string "abbreviation", limit: 255 + t.string "target_url", limit: 255 + t.integer "organisation_type_id", limit: 4 + t.string "domain", limit: 255 + t.string "wayfless_entity", limit: 255 + t.integer "stylesheet_file_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "parent_id", limit: 4 t.boolean "is_other" - t.string "sort_name" - t.text "banner_text" - t.string "logo_file_name" - t.integer "region_id" - t.integer "language_id" - t.string "logo_uid" - t.string "logo_name" - t.string "contact_email" + t.string "sort_name", limit: 255 + t.text "banner_text", limit: 65535 + t.integer "region_id", limit: 4 + t.integer "language_id", limit: 4 + t.string "logo_uid", limit: 255 + t.string "logo_name", limit: 255 + t.string "contact_email", limit: 255 end create_table "phases", force: :cascade do |t| - t.string "title" - t.text "description" - t.integer "number" - t.integer "dmptemplate_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "slug" + t.string "title", limit: 255 + t.text "description", limit: 65535 + t.integer "number", limit: 4 + t.integer "dmptemplate_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "slug", limit: 255 end - add_index "phases", ["dmptemplate_id"], name: "index_phases_on_dmptemplate_id" - add_index "phases", ["slug"], name: "index_phases_on_slug", unique: true + add_index "phases", ["dmptemplate_id"], name: "index_phases_on_dmptemplate_id", using: :btree + add_index "phases", ["slug"], name: "index_phases_on_slug", unique: true, using: :btree create_table "plan_sections", force: :cascade do |t| - t.integer "user_id" - t.integer "section_id" - t.integer "plan_id" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "user_id", limit: 4 + t.integer "section_id", limit: 4 + t.integer "plan_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.datetime "release_time" end create_table "plans", force: :cascade do |t| t.boolean "locked" - t.integer "project_id" - t.integer "version_id" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "project_id", limit: 4 + t.integer "version_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "project_groups", force: :cascade do |t| t.boolean "project_creator" t.boolean "project_editor" - t.integer "user_id" - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "user_id", limit: 4 + t.integer "project_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "project_administrator" end create_table "project_guidance", id: false, force: :cascade do |t| - t.integer "project_id", null: false - t.integer "guidance_group_id", null: false + t.integer "project_id", limit: 4, null: false + t.integer "guidance_group_id", limit: 4, null: false end - add_index "project_guidance", ["project_id", "guidance_group_id"], name: "index_project_guidance_on_project_id_and_guidance_group_id" + add_index "project_guidance", ["project_id", "guidance_group_id"], name: "index_project_guidance_on_project_id_and_guidance_group_id", using: :btree create_table "projects", force: :cascade do |t| - t.string "title" - t.integer "dmptemplate_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "slug" - t.integer "organisation_id" - t.string "grant_number" - t.string "identifier" - t.text "description" - t.string "principal_investigator" - t.string "principal_investigator_identifier" - t.string "data_contact" - t.string "funder_name" + t.string "title", limit: 255 + t.integer "dmptemplate_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "slug", limit: 255 + t.integer "organisation_id", limit: 4 + t.string "grant_number", limit: 255 + t.string "identifier", limit: 255 + t.text "description", limit: 65535 + t.string "principal_investigator", limit: 255 + t.string "principal_investigator_identifier", limit: 255 + t.string "data_contact", limit: 255 + t.string "funder_name", limit: 255 + t.boolean "is_test", default: false + t.boolean "is_public", default: false end - add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true + add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true, using: :btree create_table "question_formats", force: :cascade do |t| - t.string "title" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" + t.string "title", limit: 255 + t.text "description", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "questions", force: :cascade do |t| - t.text "text" - t.text "default_value" - t.text "guidance" - t.integer "number" - t.integer "parent_id" - t.integer "dependency_id" - t.text "dependency_text" - t.integer "section_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "question_format_id" - t.boolean "option_comment_display", default: true + t.text "text", limit: 65535 + t.text "default_value", limit: 65535 + t.text "guidance", limit: 65535 + t.integer "number", limit: 4 + t.integer "parent_id", limit: 4 + t.integer "dependency_id", limit: 4 + t.text "dependency_text", limit: 65535 + t.integer "section_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "question_format_id", limit: 4 + t.boolean "option_comment_display", default: true end create_table "questions_themes", id: false, force: :cascade do |t| - t.integer "question_id", null: false - t.integer "theme_id", null: false + t.integer "question_id", limit: 4, null: false + t.integer "theme_id", limit: 4, null: false end - add_index "questions_themes", ["question_id", "theme_id"], name: "index_questions_themes_on_question_id_and_theme_id" + add_index "questions_themes", ["question_id", "theme_id"], name: "index_questions_themes_on_question_id_and_theme_id", using: :btree create_table "region_groups", force: :cascade do |t| - t.integer "super_region_id" - t.integer "region_id" + t.integer "super_region_id", limit: 4 + t.integer "region_id", limit: 4 end create_table "regions", force: :cascade do |t| - t.string "abbreviation" - t.string "description" - t.string "name" + t.string "abbreviation", limit: 255 + t.string "description", limit: 255 + t.string "name", limit: 255 end create_table "roles", force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "role_in_plans" - t.integer "resource_id" - t.string "resource_type" + t.integer "resource_id", limit: 4 + t.string "resource_type", limit: 255 end - add_index "roles", ["name"], name: "index_roles_on_name" - add_index "roles", ["name"], name: "index_roles_on_name_and_resource_type_and_resource_id" + add_index "roles", ["name"], name: "index_roles_on_name", using: :btree + add_index "roles", ["name"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree create_table "sections", force: :cascade do |t| - t.string "title" - t.text "description" - t.integer "number" - t.integer "version_id" - t.integer "organisation_id" - t.datetime "created_at" - t.datetime "updated_at" + t.string "title", limit: 255 + t.text "description", limit: 65535 + t.integer "number", limit: 4 + t.integer "version_id", limit: 4 + t.integer "organisation_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "published" end create_table "settings", force: :cascade do |t| - t.string "var", null: false - t.text "value" - t.integer "target_id", null: false - t.string "target_type", null: false - t.datetime "created_at" - t.datetime "updated_at" + t.string "var", limit: 255, null: false + t.text "value", limit: 65535 + t.integer "target_id", limit: 4, null: false + t.string "target_type", limit: 255, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "settings", ["target_type", "target_id", "var"], name: "index_settings_on_target_type_and_target_id_and_var", unique: true + add_index "settings", ["target_type", "target_id", "var"], name: "index_settings_on_target_type_and_target_id_and_var", unique: true, using: :btree create_table "splash_logs", force: :cascade do |t| - t.string "destination" - t.datetime "created_at" - t.datetime "updated_at" + t.string "destination", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "suggested_answers", force: :cascade do |t| - t.integer "question_id" - t.integer "organisation_id" - t.text "text" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "question_id", limit: 4 + t.integer "organisation_id", limit: 4 + t.text "text", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "is_example" end create_table "themes", force: :cascade do |t| - t.string "title" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" - t.string "locale" + t.string "title", limit: 255 + t.text "description", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "locale", limit: 255 end create_table "themes_in_guidance", id: false, force: :cascade do |t| - t.integer "theme_id" - t.integer "guidance_id" + t.integer "theme_id", limit: 4 + t.integer "guidance_id", limit: 4 end create_table "token_permission_types", force: :cascade do |t| - t.string "token_type" - t.text "text_description" + t.string "token_type", limit: 255 + t.text "text_description", limit: 65535 t.datetime "created_at" t.datetime "updated_at" end create_table "user_identifiers", force: :cascade do |t| - t.string "identifier" + t.string "identifier", limit: 255 t.datetime "created_at" t.datetime "updated_at" - t.integer "user_id" - t.integer "identifier_scheme_id" + t.integer "user_id", limit: 4 + t.integer "identifier_scheme_id", limit: 4 end + add_index "user_identifiers", ["identifier_scheme_id"], name: "fk_rails_fe95df7db0", using: :btree + add_index "user_identifiers", ["user_id"], name: "fk_rails_65c9a98cdb", using: :btree + create_table "user_role_types", force: :cascade do |t| - t.string "name" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" + t.string "name", limit: 255 + t.text "description", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "user_statuses", force: :cascade do |t| - t.string "name" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" + t.string "name", limit: 255 + t.text "description", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "user_types", force: :cascade do |t| - t.string "name" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" + t.string "name", limit: 255 + t.text "description", limit: 65535 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "users", force: :cascade do |t| - t.string "firstname" - t.string "surname" - t.string "email", default: "", null: false - t.string "orcid_id" - t.string "shibboleth_id" - t.integer "user_type_id" - t.integer "user_status_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "encrypted_password", default: "" - t.string "reset_password_token" + t.string "firstname", limit: 255 + t.string "surname", limit: 255 + t.string "email", limit: 255, default: "", null: false + t.string "orcid_id", limit: 255 + t.string "shibboleth_id", limit: 255 + t.integer "user_type_id", limit: 4 + t.integer "user_status_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "encrypted_password", limit: 255, default: "" + t.string "reset_password_token", limit: 255 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0 + t.integer "sign_in_count", limit: 4, default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "confirmation_token" + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 + t.string "confirmation_token", limit: 255 t.datetime "confirmed_at" t.datetime "confirmation_sent_at" - t.string "invitation_token" + t.string "invitation_token", limit: 255 t.datetime "invitation_created_at" t.datetime "invitation_sent_at" t.datetime "invitation_accepted_at" - t.string "other_organisation" - t.boolean "dmponline3" + t.string "other_organisation", limit: 255 t.boolean "accept_terms" - t.integer "organisation_id" - t.string "api_token" - t.integer "invited_by_id" - t.string "invited_by_type" - t.integer "language_id" + t.integer "organisation_id", limit: 4 + t.string "api_token", limit: 255 + t.integer "invited_by_id", limit: 4 + t.string "invited_by_type", limit: 255 + t.integer "language_id", limit: 4 end - add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true - add_index "users", ["email"], name: "index_users_on_email", unique: true - add_index "users", ["invitation_token"], name: "index_users_on_invitation_token", unique: true - add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + add_index "users", ["invitation_token"], name: "index_users_on_invitation_token", unique: true, using: :btree + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree create_table "users_roles", id: false, force: :cascade do |t| - t.integer "user_id" - t.integer "role_id" + t.integer "user_id", limit: 4 + t.integer "role_id", limit: 4 end - add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id" + add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree create_table "versions", force: :cascade do |t| - t.string "title" - t.text "description" + t.string "title", limit: 255 + t.text "description", limit: 65535 t.boolean "published" - t.integer "number" - t.integer "phase_id" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "number", limit: 4 + t.integer "phase_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "versions", ["phase_id"], name: "index_versions_on_phase_id" + add_index "versions", ["phase_id"], name: "index_versions_on_phase_id", using: :btree + add_foreign_key "user_identifiers", "identifier_schemes" + add_foreign_key "user_identifiers", "users" end diff --git a/test/fixtures/projects.yml b/test/fixtures/projects.yml index bad5323..a9950d3 100644 --- a/test/fixtures/projects.yml +++ b/test/fixtures/projects.yml @@ -15,9 +15,13 @@ principal_investigator_identifier: '1234-ABCD' data_contact: 'someone@test.project.edu' funder_name: 'Funder 2' + is_test: false + is_public: false test_project_2: title: 'Test Project 2' dmptemplate: funder_template_3 organisation: complete - funder_name: 'Funder 2' \ No newline at end of file + funder_name: 'Funder 2' + is_test: true + is_public: false \ No newline at end of file diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 74dcab5..47d62d5 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -4,4 +4,33 @@ # test "the truth" do # assert true # end + + setup do + @project = Project.new({ + title: 'My Test Project', + dmptemplate: Dmptemplate.first, + organisation: Organisation.first + }) + end + + # ---------------------------------------------------------------------------- + test "is_public flag should be false if is_test is true" do + @project.is_public = true + @project.save! + assert_equal true, @project.is_public?, "expected the is_public flag to initially be true" + + @project.is_test = true + assert_equal false, @project.is_public?, "expected the is_public flag to switch to false" + end + + # ---------------------------------------------------------------------------- + test "is_test flag should be false if is_public is true" do + @project.is_test = true + @project.save! + assert_equal true, @project.is_test?, "expected the is_test flag to initially be true" + + @project.is_public = true + assert_equal false, @project.is_test?, "expected the is_test flag to switch to false" + end + end