• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uclibs / ucrate / b55db03c-843f-45a9-98b3-f75772ac783c

16 Apr 2025 05:43PM UTC coverage: 54.567% (-19.5%) from 74.06%
b55db03c-843f-45a9-98b3-f75772ac783c

push

circleci

web-flow
Add github workflow to trigger Teams webhook to notify for PR (#1179)

2103 of 3854 relevant lines covered (54.57%)

42.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.64
/app/api/scholar/shared_params.rb
1
module Scholar
1✔
2
  module SharedParams
1✔
3
    extend Grape::API::Helpers
1✔
4

5
    def filter_params(type) # Work type or collection
1✔
6
      declared_params = declared(params).to_a
7✔
7
      # Add special cases to allow for different types
8
      if type == 'etds' || type == 'student_works'
7✔
9
        declared_params << ["advisor", params[:advisor]] if params.key?("advisor")
×
10
        declared_params << ["degree", params[:degree]] if params.key?("degree")
×
11
        declared_params << ["committee_member", params[:committee_member]] if params.key?("committee_member")
×
12
        declared_params << ["etd_publisher", params[:etd_publisher]] if params.key?("etd_publisher")
×
13
      elsif type == 'articles'
7✔
14
        declared_params << ["journal_title", params[:journal_title]] if params.key?("journal_title")
×
15
        declared_params << ["issn", params[:issn]] if params.key?("issn")
×
16
      end
17
      if type == 'images' || type == 'student_works' || type == 'documents'
7✔
18
        declared_params << ["genre", params[:genre]] if params.key?("genre")
×
19
      end
20
      # NOTE: You must do it in this order to not fail optional fields
21
      diff = params.to_a - declared_params.to_a
7✔
22
      if diff.any?
7✔
23
        e_message = ""
×
24
        diff.each { |x| e_message << "#{x[0]} " }
×
25
        error!("Invalid parameter(s): #{e_message}", 400)
×
26
      end
27
      declared_params.to_h
7✔
28
    end
29

30
    # Required fields for all work types
31
    params :create_work do
1✔
32
      requires :email, regexp: /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
2✔
33
      requires :first_name, type: String
2✔
34
      requires :last_name, type: String
2✔
35
      requires :title, type: String
2✔
36
      requires :creator, type: String
2✔
37
      requires :description, type: String
2✔
38
      requires :license, type: String
2✔
39
      optional :create_user, type: Boolean
2✔
40
    end
41

42
    # Optional fields for updating a work
43
    params :update_work do
1✔
44
      optional :title, type: String
2✔
45
      optional :creator, type: String
2✔
46
      optional :description, type: String
2✔
47
      optional :license, type: String
2✔
48
    end
49

50
    params :optional_work do
1✔
51
      optional :access, type: String
4✔
52
      optional :college, type: String
4✔
53
      optional :department, type: String
4✔
54
      optional :date_created, type: String
4✔
55
      optional :alternate_title, type: String
4✔
56
      optional :subject, type: String
4✔
57
      optional :geo_subject, type: String
4✔
58
      optional :time_period, type: String
4✔
59
      optional :language, type: String
4✔
60
      optional :required_software, type: String
4✔
61
      optional :note, type: String
4✔
62
      optional :related_url, type: String
4✔
63
      optional :publisher, type: String
4✔
64
    end
65

66
    params :create_user do
1✔
67
      requires :email, regexp: /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
2✔
68
      requires :first_name, type: String
2✔
69
      requires :last_name, type: String
2✔
70
      requires :password, type: String
2✔
71
      requires :uc_affiliation, type: String
2✔
72
    end
73

74
    params :update_user do
1✔
75
      # Use -dot-
76
      requires :email, type: String
2✔
77
      optional :first_name, type: String
2✔
78
      optional :last_name, type: String
2✔
79
      optional :uc_affiliation, type: String
2✔
80
    end
81

82
    params :optional_user do
1✔
83
      optional :facebook_handle, type: String
4✔
84
      optional :twitter_handle, type: String
4✔
85
      optional :googleplus_handle, type: String
4✔
86
      optional :department, type: String
4✔
87
      optional :title, type: String
4✔
88
      optional :website, type: String
4✔
89
      optional :telephone, type: String
4✔
90
      optional :alternate_phone_number, type: String
4✔
91
      optional :blog, type: String
4✔
92
      optional :alternate_email, type: String
4✔
93
      optional :linkedin_handle, type: String
4✔
94
      optional :ucdepartment, type: String
4✔
95
    end
96

97
    params :create_collection do
1✔
98
      requires :title, type: String
2✔
99
      requires :email, regexp: /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
2✔
100
      requires :first_name, type: String
2✔
101
      requires :last_name, type: String
2✔
102
      requires :creator, type: String
2✔
103
      requires :description, type: String
2✔
104
      requires :license, type: String
2✔
105
      requires :access, type: String
2✔
106
    end
107

108
    params :update_collection do
1✔
109
      optional :title, type: String
2✔
110
      optional :creator, type: String
2✔
111
      optional :description, type: String
2✔
112
      optional :license, type: String
2✔
113
      optional :access, type: String
2✔
114
    end
115
  end
116
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc