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

pulibrary / orcid_princeton_hanami / 2bb26096-1bd1-42ca-a18d-a6dd2d362ec0

23 Jul 2025 04:49PM UTC coverage: 99.194% (-0.4%) from 99.589%
2bb26096-1bd1-42ca-a18d-a6dd2d362ec0

push

circleci

carolyncole
Integrating jbuilder with Tilt to correctly produce the user json
https://discourse.hanamirb.org/t/tilt-json-example/1280/3

11 of 11 new or added lines in 4 files covered. (100.0%)

4 existing lines in 2 files now uncovered.

492 of 496 relevant lines covered (99.19%)

4.41 hits per line

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

95.0
/app/actions/user/show.rb
1
# frozen_string_literal: true
2

3
module OrcidPrinceton
1✔
4
  module Actions
1✔
5
    module User
1✔
6
      # action to load and show a user
7
      class Show < OrcidPrinceton::Action
1✔
8
        include Deps['repos.user_repo',
1✔
9
                     alternative_view: 'views.errors.forbidden',
10
                     valid_view: 'views.user.show' ]
11
        before :require_authentication # make sure there is a user logged in before serving the report
1✔
12

13
        format :html, :json
1✔
14

15
        before :set_format_for_json_extension
1✔
16

17
        params do
1✔
18
          required(:id).value(:string)
1✔
19
        end
20

21
        def handle(request, response)
1✔
22
          user_id = request.params[:id].split('.').first.to_i
2✔
23
          if response[:current_user].id == user_id
2✔
24
            response[:user] = user_repo.get(user_id)
2✔
25
            response.render(valid_view, format: response.format)
2✔
26
          else
UNCOV
27
            response.render(alternative_view)
×
28
          end
29
        end
30

31
        private
1✔
32

33
        def set_format_for_json_extension(request, response)
1✔
34
          if request.params[:id].to_s.end_with?('.json')
2✔
35
            response.format = :json
1✔
36
          end
37
        end
38
      end
39
    end
40
  end
41
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

© 2025 Coveralls, Inc