diff --git a/.gitignore b/.gitignore
index b909155..74254e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,9 +32,10 @@
# ignore IDE files
.idea/*
-<<<<<<< HEAD
-=======
# ignore yard doc files
.yardoc/*
->>>>>>> 97cb77ae9aa380ac8352b49ae90b0c118aa9d2a2
+
+# ignore yard generated documents
+/doc/*
+!/doc/README_FOR_APP
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index dcc388e..e8bf467 100644
--- a/Gemfile
+++ b/Gemfile
@@ -109,6 +109,7 @@
group :test do
gem 'minitest-rails-capybara'
gem 'minitest-reporters'
+ gem 'rack-test'
end
#
diff --git a/app/admin/token_permission.rb b/app/admin/token_permission.rb
deleted file mode 100644
index ed1bd19..0000000
--- a/app/admin/token_permission.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-ActiveAdmin.register TokenPermission do
- permit_params :api_token, :token_permission_type_id, :user_id
-
- #TODO: make migration to add user_id to the model so we can have the relationship...
-
- menu priority:25, label: proc{ I18n.t('admin.token_permission')}, parent: "Api"
-
- index do
- column I18n.t('admin.user') do |n|
- link_to n.user.email, [:admin,n]
- end
- column I18n.t('admin.token_permission') do |n|
- link_to n.token_permission_type, [:admin, n]
- end
- actions
- end
-
- show do
- attributes_table do
- row :user_id
- row :token_permission_type_id
- row :api_token
- end
- end
-
- controller do
- def permitted_params
- params.permit!
- end
- end
-end
diff --git a/app/controllers/api/v0/base_controller.rb b/app/controllers/api/v0/base_controller.rb
index 020b268..c3ed859 100644
--- a/app/controllers/api/v0/base_controller.rb
+++ b/app/controllers/api/v0/base_controller.rb
@@ -103,7 +103,7 @@
def authenticate_token
authenticate_with_http_token do |token, options|
# reject the empty string as it is our base empty token
- if !token = ""
+ if token != ""
@token = token
@user = User.find_by(api_token: token)
# if no user found, return false, otherwise true
@@ -132,6 +132,7 @@
# end
# end
OrgTokenPermission.where(organisation_id: @user.organisation_id).find_each do |org_token_permission|
+ logger.debug "#{org_token_permission.token_permission_type.token_type}"
if org_token_permission.token_permission_type.token_type == auth_type
auth= true
end
diff --git a/app/controllers/api/v0/guidance_groups_controller.rb b/app/controllers/api/v0/guidance_groups_controller.rb
index f28b642..a506a0b 100644
--- a/app/controllers/api/v0/guidance_groups_controller.rb
+++ b/app/controllers/api/v0/guidance_groups_controller.rb
@@ -22,7 +22,7 @@
def show
# check if the user has permission to use the guidances api
- if has_auth("guidance")
+ if has_auth("guidances")
# determine if they have authorization to view this guidance group
if GuidanceGroup.can_view?(@user, params[:id])
respond_with get_resource
@@ -44,7 +44,7 @@
def index
- if has_auth("guidance")
+ if has_auth("guidances")
@all_viewable_groups = GuidanceGroup.all_viewable(@user)
respond_with @all_viewable_groups
else
diff --git a/app/controllers/token_permission_types_controller.rb b/app/controllers/token_permission_types_controller.rb
index 458ad69..4e1b33a 100644
--- a/app/controllers/token_permission_types_controller.rb
+++ b/app/controllers/token_permission_types_controller.rb
@@ -2,7 +2,7 @@
def index
- if user_signed_in? && user.organisation.token_permission_types.count > 0
+ if user_signed_in? && current_user.organisation.token_permission_types.count > 0
@user = current_user
respond_to do |format|
format.html
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index 6025e3b..02c490e 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -17,8 +17,8 @@
mail(to: @user.email, subject: I18n.t('helpers.main_email.access_removed'))
end
- def api_token_granted_notification(user)
- @user = user
- mail(to: @user.email, subject: I18n.t('helper.api_mail_subject')
- end
+ def api_token_granted_notification(user)
+ @user = user
+ mail(to: @user.email, subject: I18n.t('helper.api_mail_subject'))
+ end
end
\ No newline at end of file
diff --git a/app/models/token_permission.rb b/app/models/token_permission.rb
deleted file mode 100644
index 53d8567..0000000
--- a/app/models/token_permission.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class TokenPermission < ActiveRecord::Base
- attr_accessible :token_permission_type_id, :token_permission_type, :api_token, :user_id, :user, :as => [:default, :admin]
-
- #associations between tables
- belongs_to :token_permission_type
- belongs_to :user
-
-
-
-end
diff --git a/app/models/user.rb b/app/models/user.rb
index 79c4b8d..2c0064b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -14,7 +14,6 @@
has_many :project_groups, :dependent => :destroy
has_many :organisations , through: :user_org_roles
has_many :user_role_types, through: :user_org_roles
- has_many :token_permissions
diff --git a/app/views/api/v0/guidance_groups/index.json.jbuilder b/app/views/api/v0/guidance_groups/index.json.jbuilder
index b413f7b..cae2288 100644
--- a/app/views/api/v0/guidance_groups/index.json.jbuilder
+++ b/app/views/api/v0/guidance_groups/index.json.jbuilder
@@ -1,7 +1,7 @@
# builds a json response to api query for a list of guidance groups
json.prettify!
-json.guidance_group @all_viewable_groups do |guidance_group|
+json.guidance_groups @all_viewable_groups do |guidance_group|
json.name guidance_group.name
json.id guidance_group.id
diff --git a/app/views/users/admin_api_update.html.erb b/app/views/users/admin_api_update.html.erb
new file mode 100644
index 0000000..e7e94f1
--- /dev/null
+++ b/app/views/users/admin_api_update.html.erb
@@ -0,0 +1,56 @@
+<%= stylesheet_link_tag "admin" %>
+
+
+ <%= t('org_admin.users_list') %>
+
+
+<%= raw t('org_admin.user_text_html')%>
+<% @users = current_user.organisation.users %>
+
+
+
+ | <%= t('org_admin.user_full_name') %> |
+ <%= t('org_admin.user_name') %> |
+ <%= t('org_admin.last_logged_in') %> |
+ <%= t('org_admin.how_many_plans') %> |
+ <% if current_user.organisation.token_permission_types.count > 0 %>
+ <%= t('org_admin.api_privleges') %> |
+ <% end %>
+
+
+
+
+ <%= form_tag( admin_api_update_users_path, method: :put) do %>
+ <% @users.each do |user| %>
+ <% if !user.nil? then%>
+
+ |
+ <% if !user.name.nil? then%>
+ <%= user.name %>
+ <% end %>
+ |
+
+ <%= user.email %>
+ |
+
+ <% if !user.last_sign_in_at.nil? then%>
+ <%= l user.last_sign_in_at.to_date, :formats => :short %>
+ <% end %>
+ |
+
+ <% if !user.project_groups.nil? then%>
+ <%= user.project_groups.count %>
+ <% end %>
+ |
+ <% if current_user.organisation.token_permission_types.count > 0 %>
+
+ <%= check_box_tag "user_ids[]", user.id, user.api_token !="" %>
+ |
+ <% end %>
+
+ <% end %>
+ <% end %>
+
+ <%= submit_tag "Update API Privleges" %>
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/admin_index.html.erb b/app/views/users/admin_index.html.erb
index 33a717e..e7e94f1 100644
--- a/app/views/users/admin_index.html.erb
+++ b/app/views/users/admin_index.html.erb
@@ -5,8 +5,7 @@
<%= raw t('org_admin.user_text_html')%>
-<% @user_roles = current_user.organisation.user_org_roles %>
-<% @user_roles = @user_roles.uniq_by {|u| u.user_id } %>
+<% @users = current_user.organisation.users %>
@@ -22,30 +21,30 @@
<%= form_tag( admin_api_update_users_path, method: :put) do %>
- <% @user_roles.each do |user_id| %>
- <% if !user_id.user.nil? then%>
+ <% @users.each do |user| %>
+ <% if !user.nil? then%>
|
- <% if !user_id.user.name.nil? then%>
- <%= user_id.user.name %>
+ <% if !user.name.nil? then%>
+ <%= user.name %>
<% end %>
|
- <%= user_id.user.email %>
+ <%= user.email %>
|
- <% if !user_id.user.last_sign_in_at.nil? then%>
- <%= l user_id.user.last_sign_in_at.to_date, :formats => :short %>
+ <% if !user.last_sign_in_at.nil? then%>
+ <%= l user.last_sign_in_at.to_date, :formats => :short %>
<% end %>
|
- <% if !user_id.user.project_groups.nil? then%>
- <%= user_id.user.project_groups.count %>
+ <% if !user.project_groups.nil? then%>
+ <%= user.project_groups.count %>
<% end %>
|
<% if current_user.organisation.token_permission_types.count > 0 %>
- <%= check_box_tag "user_ids[]", user_id.user.id, user_id.user.api_token !="" %>
+ <%= check_box_tag "user_ids[]", user.id, user.api_token !="" %>
|
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index eedc121..6d342ee 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,7 @@
Rails.application.routes.draw do
get "about_us" => 'static_pages#about_us', :as => "about_us"
get "help" => 'static_pages#help', :as => "help"
+ get "roadmap" => 'static_pages#roadmap', :as => "roadmap"
get "news" => 'static_pages#news', :as => "news"
get "terms" => 'static_pages#termsuse', :as => "terms"
get "existing_users" => 'existing_users#index', :as => "existing_users"
diff --git a/db/schema.rb b/db/schema.rb
index 603f825..a7e5f15 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -18,8 +18,8 @@
t.integer "plan_id", limit: 4
t.integer "user_id", limit: 4
t.integer "question_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "answers_options", id: false, force: :cascade do |t|
@@ -33,8 +33,8 @@
t.integer "user_id", limit: 4
t.integer "question_id", limit: 4
t.text "text", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "archived", limit: 1
t.integer "plan_id", limit: 4
t.integer "archived_by", limit: 4
@@ -46,8 +46,8 @@
t.boolean "published", limit: 1
t.integer "user_id", limit: 4
t.integer "organisation_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "locale", limit: 255
t.boolean "is_default", limit: 1
end
@@ -61,8 +61,8 @@
t.integer "plan_id", limit: 4
t.integer "user_id", limit: 4
t.string "format", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "file_types", force: :cascade do |t|
@@ -70,8 +70,8 @@
t.string "icon_name", limit: 255
t.integer "icon_size", limit: 4
t.string "icon_location", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "file_uploads", force: :cascade do |t|
@@ -82,13 +82,13 @@
t.boolean "published", limit: 1
t.string "location", limit: 255
t.integer "file_type_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "friendly_id_slugs", force: true do |t|
- t.string "slug", limit: 191, null: false
- t.integer "sluggable_id", null: false
+ create_table "friendly_id_slugs", force: :cascade do |t|
+ 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
@@ -100,8 +100,8 @@
create_table "guidance_groups", force: :cascade do |t|
t.string "name", limit: 255
t.integer "organisation_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "optional_subset", limit: 1
t.boolean "published", limit: 1
end
@@ -116,24 +116,24 @@
create_table "guidances", force: :cascade do |t|
t.text "text", limit: 65535
t.integer "guidance_group_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "question_id", limit: 4
t.boolean "published", limit: 1
end
- create_table "languages", force: true do |t|
- t.string "abbreviation"
- t.string "description"
- t.string "name"
+ create_table "languages", force: :cascade do |t|
+ t.string "abbreviation", limit: 255
+ t.string "description", limit: 255
+ t.string "name", limit: 255
end
- create_table "option_warnings", force: true do |t|
- t.integer "organisation_id"
- t.integer "option_id"
- t.text "text"
- t.datetime "created_at"
- t.datetime "updated_at"
+ create_table "option_warnings", force: :cascade do |t|
+ 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|
@@ -141,8 +141,8 @@
t.string "text", limit: 255
t.integer "number", limit: 4
t.boolean "is_default", limit: 1
- 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|
@@ -155,8 +155,8 @@
create_table "organisation_types", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "organisations", force: :cascade do |t|
@@ -168,8 +168,8 @@
t.string "domain", limit: 255
t.string "wayfless_entity", limit: 255
t.integer "stylesheet_file_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "parent_id", limit: 4
t.boolean "is_other", limit: 1
t.string "sort_name", limit: 255
@@ -182,9 +182,9 @@
t.text "description", limit: 65535
t.integer "number", limit: 4
t.integer "dmptemplate_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "slug", limit: 191
+ 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", using: :btree
@@ -194,8 +194,8 @@
t.integer "user_id", limit: 4
t.integer "section_id", limit: 4
t.integer "plan_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.datetime "release_time"
end
@@ -203,8 +203,8 @@
t.boolean "locked", limit: 1
t.integer "project_id", limit: 4
t.integer "version_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "project_groups", force: :cascade do |t|
@@ -212,8 +212,8 @@
t.boolean "project_editor", limit: 1
t.integer "user_id", limit: 4
t.integer "project_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "project_administrator", limit: 1
end
@@ -227,17 +227,17 @@
create_table "projects", force: :cascade do |t|
t.string "title", limit: 255
t.integer "dmptemplate_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "slug", limit: 191
- 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.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
end
add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true, using: :btree
@@ -245,8 +245,8 @@
create_table "question_formats", force: :cascade do |t|
t.string "title", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "questions", force: :cascade do |t|
@@ -258,8 +258,8 @@
t.integer "dependency_id", limit: 4
t.text "dependency_text", limit: 65535
t.integer "section_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "question_format_id", limit: 4
t.boolean "option_comment_display", limit: 1, default: true
end
@@ -271,10 +271,10 @@
add_index "questions_themes", ["question_id", "theme_id"], name: "index_questions_themes_on_question_id_and_theme_id", using: :btree
- create_table "roles", force: true do |t|
- t.string "name", limit: 191
- t.datetime "created_at"
- t.datetime "updated_at"
+ create_table "roles", force: :cascade do |t|
+ t.string "name", limit: 255
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "role_in_plans", limit: 1
t.integer "resource_id", limit: 4
t.string "resource_type", limit: 255
@@ -289,42 +289,42 @@
t.integer "number", limit: 4
t.integer "version_id", limit: 4
t.integer "organisation_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "published", limit: 1
end
- create_table "settings", force: true do |t|
- t.string "var", limit: 191, null: false
- t.text "value"
- t.integer "target_id", null: false
- t.string "target_type", limit: 191, null: false
- t.datetime "created_at"
- t.datetime "updated_at"
+ create_table "settings", force: :cascade do |t|
+ 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, using: :btree
create_table "splash_logs", force: :cascade do |t|
t.string "destination", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
+ 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", limit: 4
t.integer "organisation_id", limit: 4
t.text "text", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "is_example", limit: 1
end
create_table "themes", force: :cascade do |t|
t.string "title", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "locale", limit: 255
end
@@ -340,63 +340,62 @@
t.datetime "updated_at"
end
- create_table "user_org_roles", force: true do |t|
- t.integer "user_id"
- t.integer "organisation_id"
- t.integer "user_role_type_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ create_table "user_org_roles", force: :cascade do |t|
+ t.integer "user_id", limit: 4
+ t.integer "organisation_id", limit: 4
+ t.integer "user_role_type_id", limit: 4
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "user_role_types", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "user_statuses", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "user_types", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "users", force: true do |t|
- t.string "firstname"
- t.string "surname"
- t.string "email", limit: 191, 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", limit: 191
+ create_table "users", force: :cascade do |t|
+ 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", limit: 191
+ 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", limit: 191
+ 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", limit: 255
- t.boolean "dmponline3", limit: 1
t.boolean "accept_terms", limit: 1
t.integer "organisation_id", limit: 4
t.string "api_token", limit: 255
@@ -422,8 +421,8 @@
t.boolean "published", limit: 1
t.integer "number", limit: 4
t.integer "phase_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
add_index "versions", ["phase_id"], name: "index_versions_on_phase_id", using: :btree
diff --git a/test/fixtures/dmptemplates_guidance_groups.yml b/test/fixtures/dmptemplates_guidance_groups.yml
deleted file mode 100644
index f49066a..0000000
--- a/test/fixtures/dmptemplates_guidance_groups.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-# dcc_template_1:
-# guidance_group: dcc_guidance_group_1
-# dmptemplate: dcc_template
-
-# ahrc_template_1:
-# guidance_group: funder_guidance_group_1
-# dmptemplate: ahrc_template
-
-# bbsrc_template_1:
-# guidance_group: funder_guidance_group_2
-# dmptemplate: bbsrc_template
-
-# aru_template_1:
-# guidance_group: institution_guidance_group_1
-# dmptemplate: aru_template
-
-# au_template_1:
-# guidance_group: institution_guidance_group_2
-# dmptemplate: au_template
-
-# bu_template_1:
-# guidance_group: institution_guidance_group_3
-# dmptemplate: bu_template
-
-# bu_template_2:
-# guidance_group: institution_guidance_group_4
-# dmptemplate: bu_template
\ No newline at end of file
diff --git a/test/fixtures/guidances.yml b/test/fixtures/guidances.yml
index d8479f1..0474bd2 100644
--- a/test/fixtures/guidances.yml
+++ b/test/fixtures/guidances.yml
@@ -168,7 +168,9 @@
text: "sample institution guidance bu 2"
themes: embargo_period
-
+one:
+ text: "one"
+ themes: embargo_period
diff --git a/test/fixtures/org_token_permissions.yml b/test/fixtures/org_token_permissions.yml
new file mode 100644
index 0000000..7f1a3a3
--- /dev/null
+++ b/test/fixtures/org_token_permissions.yml
@@ -0,0 +1,15 @@
+dcc_one:
+ token_permission_type: plans_token_type
+ organisation: dcc
+
+dcc_two:
+ token_permission_type: guidances_token_type
+ organisation: dcc
+
+aru_one:
+ token_permission_type: plans_token_type
+ organisation: aru
+
+au_one:
+ token_permission_type: guidances_token_type
+ organisation: au
\ No newline at end of file
diff --git a/test/fixtures/token_permission.yml b/test/fixtures/token_permission.yml
deleted file mode 100644
index 8a3003c..0000000
--- a/test/fixtures/token_permission.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-guidances_api_token:
- token_permission_type: guidances_token_type
- api_token: "guidances_api_token"
- user: user_one
-
-plans_api_token:
- token_permission_type: plans_token_type
- api_token: "plans_api_token"
- user: user_two
-
diff --git a/test/fixtures/token_permission_type.yml b/test/fixtures/token_permission_type.yml
deleted file mode 100644
index 5056f18..0000000
--- a/test/fixtures/token_permission_type.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-guidances_token_type:
- token_type: "guidance"
- text_desription: "allows access to the guidance api"
-
-plans_token_type:
- token_type: "plan"
- text_desription: "allows access to the plan api"
diff --git a/test/fixtures/user_org_roles.yml b/test/fixtures/user_org_roles.yml
index a08038e..403e83c 100644
--- a/test/fixtures/user_org_roles.yml
+++ b/test/fixtures/user_org_roles.yml
@@ -22,3 +22,8 @@
three:
user: user_three
organisation: bu
+
+dcc_user_1:
+ user: user_dcc
+ organisation: dcc
+
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
index 04d40ab..4d9373a 100644
--- a/test/fixtures/users.yml
+++ b/test/fixtures/users.yml
@@ -38,3 +38,11 @@
firstname: Many
surname: Projects
email: many.projects@example.com
+
+user_dcc:
+ firstname: "john"
+ surname: "doe"
+ email: "me@dcc.net"
+ user_type_id: 1
+ user_status_id: 1
+ api_token: "wasd"
\ No newline at end of file
diff --git a/test/functional/api_projects_controller_test.rb b/test/functional/api_projects_controller_test.rb
new file mode 100644
index 0000000..d47d190
--- /dev/null
+++ b/test/functional/api_projects_controller_test.rb
@@ -0,0 +1,57 @@
+require 'test_helper'
+require "rack/test"
+
+class ApiProjectsControllerTest < ActiveSupport::TestCase
+ include Rack::Test::Methods
+
+ def app
+ MyApp.new
+ end
+
+ @controller = Api::V0::ProjectsController.new
+
+ test "create validates that a user has plans auth" do
+ # has auth for projects
+ @user = users(:user_dcc)
+ post :create, params: {template:{organisation: "Arts and Humanities Research Council"},project:{title:"my project", email:"org_admin@example.com"}}
+ assert_response :success
+
+ # has no auth for projects
+ # @user = users(:user_three)
+ # post :create, params: {template:{organisation: "Arts and Humanities Research Council"},project:{title:"my project", email:"org_admin@example.com"}}
+ # assert_response 400
+ end
+
+ test "create validates that the passed organisation exists" do
+ flunk
+ end
+
+ test "create validates that the passed organisation is a funder" do
+ flunk
+ end
+
+ test "create validates that the passed organisation has only 1 template" do
+ flunk
+ end
+
+ test "create validates that a passed organisation with more than one template specifies template" do
+ flunk
+ end
+
+ test "create checks for a guidance and adds it if it exists" do
+ flunk
+ end
+
+ test "create checks for guidances and adds them if they exist" do
+ flunk
+ end
+
+ test "create invites is user email not already in system" do
+ flunk
+ end
+
+ test "create creates a new project when params correct" do
+ flunk
+ end
+
+end
\ No newline at end of file