├── .gitignore ├── .graphiticfg.yml ├── .rspec ├── .tool-versions ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ ├── departments_controller.rb │ ├── employees_controller.rb │ ├── milestones_controller.rb │ ├── notes_controller.rb │ ├── positions_controller.rb │ ├── tasks_controller.rb │ └── teams_controller.rb ├── jobs │ └── application_job.rb ├── mailers │ └── application_mailer.rb ├── models │ ├── application_record.rb │ ├── bug.rb │ ├── concerns │ │ └── .keep │ ├── department.rb │ ├── employee.rb │ ├── epic.rb │ ├── feature.rb │ ├── milestone.rb │ ├── note.rb │ ├── position.rb │ ├── task.rb │ ├── team.rb │ └── team_membership.rb ├── resources │ ├── application_resource.rb │ ├── bug_resource.rb │ ├── department_resource.rb │ ├── employee_resource.rb │ ├── epic_resource.rb │ ├── feature_resource.rb │ ├── milestone_resource.rb │ ├── note_resource.rb │ ├── position_resource.rb │ ├── task_resource.rb │ └── team_resource.rb └── views │ └── layouts │ ├── mailer.html.erb │ └── mailer.text.erb ├── bin ├── bundle ├── rails ├── rake ├── rspec ├── setup ├── spring └── update ├── config.ru ├── config ├── application.rb ├── boot.rb ├── cable.yml ├── credentials.yml.enc ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── application_controller_renderer.rb │ ├── backtrace_silencers.rb │ ├── cors.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── puma.rb ├── routes.rb ├── spring.rb └── storage.yml ├── db ├── migrate │ ├── 20180903174755_create_employees.rb │ ├── 20180903175706_create_positions.rb │ ├── 20180904115831_create_departments.rb │ ├── 20180904120042_add_department_id_to_positions.rb │ ├── 20180904123419_create_teams.rb │ ├── 20180904123442_create_team_memberships.rb │ ├── 20180904141521_create_notes.rb │ ├── 20180904143550_create_tasks.rb │ └── 20180904143830_create_milestones.rb ├── schema.rb └── seeds.rb ├── lib └── tasks │ └── .keep ├── log └── .keep ├── public ├── api │ └── v1 │ │ ├── schema.json │ │ └── vandal │ │ ├── assets │ │ └── img │ │ │ └── squares.png │ │ ├── css │ │ ├── app.59d17783.css │ │ └── chunk-vendors.e6a6ca22.css │ │ ├── favicon.ico │ │ ├── index.html │ │ └── js │ │ ├── app.d38ac258.js │ │ ├── app.d38ac258.js.map │ │ ├── app.f85601e5.js │ │ ├── app.f85601e5.js.map │ │ ├── chunk-vendors.326f67bb.js │ │ └── chunk-vendors.326f67bb.js.map └── robots.txt ├── spec ├── api │ └── v1 │ │ ├── departments │ │ ├── create_spec.rb │ │ ├── destroy_spec.rb │ │ ├── index_spec.rb │ │ ├── show_spec.rb │ │ └── update_spec.rb │ │ ├── employees │ │ ├── create_spec.rb │ │ ├── destroy_spec.rb │ │ ├── index_spec.rb │ │ ├── show_spec.rb │ │ └── update_spec.rb │ │ ├── milestones │ │ ├── create_spec.rb │ │ ├── destroy_spec.rb │ │ ├── index_spec.rb │ │ ├── show_spec.rb │ │ └── update_spec.rb │ │ ├── notes │ │ ├── create_spec.rb │ │ ├── destroy_spec.rb │ │ ├── index_spec.rb │ │ ├── show_spec.rb │ │ └── update_spec.rb │ │ ├── positions │ │ ├── create_spec.rb │ │ ├── destroy_spec.rb │ │ ├── index_spec.rb │ │ ├── show_spec.rb │ │ └── update_spec.rb │ │ ├── tasks │ │ ├── create_spec.rb │ │ ├── destroy_spec.rb │ │ ├── index_spec.rb │ │ ├── show_spec.rb │ │ └── update_spec.rb │ │ └── teams │ │ ├── create_spec.rb │ │ ├── destroy_spec.rb │ │ ├── index_spec.rb │ │ ├── show_spec.rb │ │ └── update_spec.rb ├── factories │ ├── departments.rb │ ├── employees.rb │ ├── milestones.rb │ ├── notes.rb │ ├── positions.rb │ ├── tasks.rb │ ├── team_memberships.rb │ └── teams.rb ├── models │ └── position_spec.rb ├── rails_helper.rb ├── resources │ ├── department │ │ ├── reads_spec.rb │ │ └── writes_spec.rb │ ├── employee │ │ ├── reads_spec.rb │ │ └── writes_spec.rb │ ├── milestone │ │ ├── reads_spec.rb │ │ └── writes_spec.rb │ ├── note │ │ ├── reads_spec.rb │ │ └── writes_spec.rb │ ├── position │ │ ├── reads_spec.rb │ │ └── writes_spec.rb │ ├── task │ │ ├── reads_spec.rb │ │ └── writes_spec.rb │ └── team │ │ ├── reads_spec.rb │ │ └── writes_spec.rb └── spec_helper.rb ├── storage └── .keep ├── tmp └── .keep └── vendor └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | # Ignore uploaded files in development 21 | /storage/* 22 | !/storage/.keep 23 | 24 | .byebug_history 25 | 26 | # Ignore master key for decrypting credentials and more. 27 | /config/master.key 28 | -------------------------------------------------------------------------------- /.graphiticfg.yml: -------------------------------------------------------------------------------- 1 | --- 2 | namespace: "/api/v1" 3 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | ruby 3.3.7 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby '3.3.7' 5 | 6 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7 | gem 'rails', '~> 8.0.2' 8 | # Use sqlite3 as the database for Active Record 9 | gem 'sqlite3' 10 | # Use Puma as the app server 11 | gem 'puma' 12 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 13 | # gem 'jbuilder', '~> 2.5' 14 | # Use Redis adapter to run Action Cable in production 15 | # gem 'redis', '~> 4.0' 16 | # Use ActiveModel has_secure_password 17 | # gem 'bcrypt', '~> 3.1.7' 18 | 19 | # Use ActiveStorage variant 20 | # gem 'mini_magick', '~> 4.8' 21 | 22 | # Use Capistrano for deployment 23 | # gem 'capistrano-rails', group: :development 24 | 25 | # Reduces boot times through caching; required in config/boot.rb 26 | gem 'bootsnap', require: false 27 | 28 | # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible 29 | gem 'rack-cors' 30 | 31 | group :development, :test do 32 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 33 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 34 | end 35 | 36 | group :development do 37 | gem 'listen' 38 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 39 | gem 'spring' 40 | gem 'spring-watcher-listen', '~> 2.0.0' 41 | end 42 | 43 | 44 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 45 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 46 | 47 | gem 'graphiti' 48 | gem 'graphiti-rails' 49 | gem 'vandal_ui' 50 | gem 'kaminari' 51 | gem 'responders' 52 | group :development, :test do 53 | gem 'rspec-rails' 54 | gem 'factory_bot_rails' 55 | gem 'faker' 56 | gem 'graphiti_spec_helpers' 57 | end 58 | 59 | group :test do 60 | gem 'database_cleaner', '~> 1.6' 61 | end 62 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (8.0.2) 5 | actionpack (= 8.0.2) 6 | activesupport (= 8.0.2) 7 | nio4r (~> 2.0) 8 | websocket-driver (>= 0.6.1) 9 | zeitwerk (~> 2.6) 10 | actionmailbox (8.0.2) 11 | actionpack (= 8.0.2) 12 | activejob (= 8.0.2) 13 | activerecord (= 8.0.2) 14 | activestorage (= 8.0.2) 15 | activesupport (= 8.0.2) 16 | mail (>= 2.8.0) 17 | actionmailer (8.0.2) 18 | actionpack (= 8.0.2) 19 | actionview (= 8.0.2) 20 | activejob (= 8.0.2) 21 | activesupport (= 8.0.2) 22 | mail (>= 2.8.0) 23 | rails-dom-testing (~> 2.2) 24 | actionpack (8.0.2) 25 | actionview (= 8.0.2) 26 | activesupport (= 8.0.2) 27 | nokogiri (>= 1.8.5) 28 | rack (>= 2.2.4) 29 | rack-session (>= 1.0.1) 30 | rack-test (>= 0.6.3) 31 | rails-dom-testing (~> 2.2) 32 | rails-html-sanitizer (~> 1.6) 33 | useragent (~> 0.16) 34 | actiontext (8.0.2) 35 | actionpack (= 8.0.2) 36 | activerecord (= 8.0.2) 37 | activestorage (= 8.0.2) 38 | activesupport (= 8.0.2) 39 | globalid (>= 0.6.0) 40 | nokogiri (>= 1.8.5) 41 | actionview (8.0.2) 42 | activesupport (= 8.0.2) 43 | builder (~> 3.1) 44 | erubi (~> 1.11) 45 | rails-dom-testing (~> 2.2) 46 | rails-html-sanitizer (~> 1.6) 47 | activejob (8.0.2) 48 | activesupport (= 8.0.2) 49 | globalid (>= 0.3.6) 50 | activemodel (8.0.2) 51 | activesupport (= 8.0.2) 52 | activerecord (8.0.2) 53 | activemodel (= 8.0.2) 54 | activesupport (= 8.0.2) 55 | timeout (>= 0.4.0) 56 | activestorage (8.0.2) 57 | actionpack (= 8.0.2) 58 | activejob (= 8.0.2) 59 | activerecord (= 8.0.2) 60 | activesupport (= 8.0.2) 61 | marcel (~> 1.0) 62 | activesupport (8.0.2) 63 | base64 64 | benchmark (>= 0.3) 65 | bigdecimal 66 | concurrent-ruby (~> 1.0, >= 1.3.1) 67 | connection_pool (>= 2.2.5) 68 | drb 69 | i18n (>= 1.6, < 2) 70 | logger (>= 1.4.2) 71 | minitest (>= 5.1) 72 | securerandom (>= 0.3) 73 | tzinfo (~> 2.0, >= 2.0.5) 74 | uri (>= 0.13.1) 75 | base64 (0.2.0) 76 | benchmark (0.4.0) 77 | bigdecimal (3.1.9) 78 | bootsnap (1.18.4) 79 | msgpack (~> 1.2) 80 | builder (3.3.0) 81 | byebug (11.1.3) 82 | concurrent-ruby (1.3.5) 83 | connection_pool (2.5.0) 84 | crass (1.0.6) 85 | database_cleaner (1.99.0) 86 | date (3.4.1) 87 | diff-lcs (1.6.0) 88 | drb (2.2.1) 89 | dry-core (1.1.0) 90 | concurrent-ruby (~> 1.0) 91 | logger 92 | zeitwerk (~> 2.6) 93 | dry-inflector (1.2.0) 94 | dry-logic (1.6.0) 95 | bigdecimal 96 | concurrent-ruby (~> 1.0) 97 | dry-core (~> 1.1) 98 | zeitwerk (~> 2.6) 99 | dry-types (1.8.2) 100 | bigdecimal (~> 3.0) 101 | concurrent-ruby (~> 1.0) 102 | dry-core (~> 1.0) 103 | dry-inflector (~> 1.0) 104 | dry-logic (~> 1.4) 105 | zeitwerk (~> 2.6) 106 | erubi (1.13.1) 107 | factory_bot (6.5.1) 108 | activesupport (>= 6.1.0) 109 | factory_bot_rails (6.4.4) 110 | factory_bot (~> 6.5) 111 | railties (>= 5.0.0) 112 | faker (3.5.1) 113 | i18n (>= 1.8.11, < 2) 114 | ffi (1.17.1-aarch64-linux-gnu) 115 | ffi (1.17.1-aarch64-linux-musl) 116 | ffi (1.17.1-arm-linux-gnu) 117 | ffi (1.17.1-arm-linux-musl) 118 | ffi (1.17.1-arm64-darwin) 119 | ffi (1.17.1-x86_64-darwin) 120 | ffi (1.17.1-x86_64-linux-gnu) 121 | ffi (1.17.1-x86_64-linux-musl) 122 | globalid (1.2.1) 123 | activesupport (>= 6.1) 124 | graphiti (1.8.1) 125 | activesupport (>= 5.2) 126 | concurrent-ruby (>= 1.2, < 2.0) 127 | dry-types (>= 0.15.0, < 2.0) 128 | graphiti_errors (~> 1.1.0) 129 | jsonapi-renderer (~> 0.2, >= 0.2.2) 130 | jsonapi-serializable (~> 0.3.0) 131 | graphiti-rails (0.4.1) 132 | graphiti (~> 1.2) 133 | railties (>= 5.0) 134 | rescue_registry (~> 1.0) 135 | graphiti_errors (1.1.2) 136 | jsonapi-serializable (~> 0.1) 137 | graphiti_spec_helpers (1.2.0) 138 | graphiti (>= 1.0.alpha.1) 139 | rspec (~> 3.0) 140 | i18n (1.14.7) 141 | concurrent-ruby (~> 1.0) 142 | io-console (0.8.0) 143 | irb (1.15.1) 144 | pp (>= 0.6.0) 145 | rdoc (>= 4.0.0) 146 | reline (>= 0.4.2) 147 | jsonapi-renderer (0.2.2) 148 | jsonapi-serializable (0.3.1) 149 | jsonapi-renderer (~> 0.2.0) 150 | kaminari (1.2.2) 151 | activesupport (>= 4.1.0) 152 | kaminari-actionview (= 1.2.2) 153 | kaminari-activerecord (= 1.2.2) 154 | kaminari-core (= 1.2.2) 155 | kaminari-actionview (1.2.2) 156 | actionview 157 | kaminari-core (= 1.2.2) 158 | kaminari-activerecord (1.2.2) 159 | activerecord 160 | kaminari-core (= 1.2.2) 161 | kaminari-core (1.2.2) 162 | listen (3.9.0) 163 | rb-fsevent (~> 0.10, >= 0.10.3) 164 | rb-inotify (~> 0.9, >= 0.9.10) 165 | logger (1.6.6) 166 | loofah (2.24.0) 167 | crass (~> 1.0.2) 168 | nokogiri (>= 1.12.0) 169 | mail (2.8.1) 170 | mini_mime (>= 0.1.1) 171 | net-imap 172 | net-pop 173 | net-smtp 174 | marcel (1.0.4) 175 | mini_mime (1.1.5) 176 | minitest (5.25.5) 177 | msgpack (1.8.0) 178 | net-imap (0.5.6) 179 | date 180 | net-protocol 181 | net-pop (0.1.2) 182 | net-protocol 183 | net-protocol (0.2.2) 184 | timeout 185 | net-smtp (0.5.1) 186 | net-protocol 187 | nio4r (2.7.4) 188 | nokogiri (1.18.5-aarch64-linux-gnu) 189 | racc (~> 1.4) 190 | nokogiri (1.18.5-aarch64-linux-musl) 191 | racc (~> 1.4) 192 | nokogiri (1.18.5-arm-linux-gnu) 193 | racc (~> 1.4) 194 | nokogiri (1.18.5-arm-linux-musl) 195 | racc (~> 1.4) 196 | nokogiri (1.18.5-arm64-darwin) 197 | racc (~> 1.4) 198 | nokogiri (1.18.5-x86_64-darwin) 199 | racc (~> 1.4) 200 | nokogiri (1.18.5-x86_64-linux-gnu) 201 | racc (~> 1.4) 202 | nokogiri (1.18.5-x86_64-linux-musl) 203 | racc (~> 1.4) 204 | pp (0.6.2) 205 | prettyprint 206 | prettyprint (0.2.0) 207 | psych (5.2.3) 208 | date 209 | stringio 210 | puma (6.6.0) 211 | nio4r (~> 2.0) 212 | racc (1.8.1) 213 | rack (3.1.12) 214 | rack-cors (2.0.2) 215 | rack (>= 2.0.0) 216 | rack-session (2.1.0) 217 | base64 (>= 0.1.0) 218 | rack (>= 3.0.0) 219 | rack-test (2.2.0) 220 | rack (>= 1.3) 221 | rackup (2.2.1) 222 | rack (>= 3) 223 | rails (8.0.2) 224 | actioncable (= 8.0.2) 225 | actionmailbox (= 8.0.2) 226 | actionmailer (= 8.0.2) 227 | actionpack (= 8.0.2) 228 | actiontext (= 8.0.2) 229 | actionview (= 8.0.2) 230 | activejob (= 8.0.2) 231 | activemodel (= 8.0.2) 232 | activerecord (= 8.0.2) 233 | activestorage (= 8.0.2) 234 | activesupport (= 8.0.2) 235 | bundler (>= 1.15.0) 236 | railties (= 8.0.2) 237 | rails-dom-testing (2.2.0) 238 | activesupport (>= 5.0.0) 239 | minitest 240 | nokogiri (>= 1.6) 241 | rails-html-sanitizer (1.6.2) 242 | loofah (~> 2.21) 243 | nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) 244 | railties (8.0.2) 245 | actionpack (= 8.0.2) 246 | activesupport (= 8.0.2) 247 | irb (~> 1.13) 248 | rackup (>= 1.0.0) 249 | rake (>= 12.2) 250 | thor (~> 1.0, >= 1.2.2) 251 | zeitwerk (~> 2.6) 252 | rake (13.2.1) 253 | rb-fsevent (0.11.2) 254 | rb-inotify (0.11.1) 255 | ffi (~> 1.0) 256 | rdoc (6.12.0) 257 | psych (>= 4.0.0) 258 | reline (0.6.0) 259 | io-console (~> 0.5) 260 | rescue_registry (1.0.0) 261 | activesupport (>= 5.0) 262 | responders (3.1.1) 263 | actionpack (>= 5.2) 264 | railties (>= 5.2) 265 | rspec (3.13.0) 266 | rspec-core (~> 3.13.0) 267 | rspec-expectations (~> 3.13.0) 268 | rspec-mocks (~> 3.13.0) 269 | rspec-core (3.13.3) 270 | rspec-support (~> 3.13.0) 271 | rspec-expectations (3.13.3) 272 | diff-lcs (>= 1.2.0, < 2.0) 273 | rspec-support (~> 3.13.0) 274 | rspec-mocks (3.13.2) 275 | diff-lcs (>= 1.2.0, < 2.0) 276 | rspec-support (~> 3.13.0) 277 | rspec-rails (7.1.1) 278 | actionpack (>= 7.0) 279 | activesupport (>= 7.0) 280 | railties (>= 7.0) 281 | rspec-core (~> 3.13) 282 | rspec-expectations (~> 3.13) 283 | rspec-mocks (~> 3.13) 284 | rspec-support (~> 3.13) 285 | rspec-support (3.13.2) 286 | securerandom (0.4.1) 287 | spring (2.1.1) 288 | spring-watcher-listen (2.0.1) 289 | listen (>= 2.7, < 4.0) 290 | spring (>= 1.2, < 3.0) 291 | sqlite3 (2.6.0-aarch64-linux-gnu) 292 | sqlite3 (2.6.0-aarch64-linux-musl) 293 | sqlite3 (2.6.0-arm-linux-gnu) 294 | sqlite3 (2.6.0-arm-linux-musl) 295 | sqlite3 (2.6.0-arm64-darwin) 296 | sqlite3 (2.6.0-x86_64-darwin) 297 | sqlite3 (2.6.0-x86_64-linux-gnu) 298 | sqlite3 (2.6.0-x86_64-linux-musl) 299 | stringio (3.1.5) 300 | thor (1.3.2) 301 | timeout (0.4.3) 302 | tzinfo (2.0.6) 303 | concurrent-ruby (~> 1.0) 304 | uri (1.0.3) 305 | useragent (0.16.11) 306 | vandal_ui (0.4.5) 307 | websocket-driver (0.7.7) 308 | base64 309 | websocket-extensions (>= 0.1.0) 310 | websocket-extensions (0.1.5) 311 | zeitwerk (2.7.2) 312 | 313 | PLATFORMS 314 | aarch64-linux-gnu 315 | aarch64-linux-musl 316 | arm-linux-gnu 317 | arm-linux-musl 318 | arm64-darwin 319 | x86_64-darwin 320 | x86_64-linux-gnu 321 | x86_64-linux-musl 322 | 323 | DEPENDENCIES 324 | bootsnap 325 | byebug 326 | database_cleaner (~> 1.6) 327 | factory_bot_rails 328 | faker 329 | graphiti 330 | graphiti-rails 331 | graphiti_spec_helpers 332 | kaminari 333 | listen 334 | puma 335 | rack-cors 336 | rails (~> 8.0.2) 337 | responders 338 | rspec-rails 339 | spring 340 | spring-watcher-listen (~> 2.0.0) 341 | sqlite3 342 | tzinfo-data 343 | vandal_ui 344 | 345 | RUBY VERSION 346 | ruby 3.3.7p123 347 | 348 | BUNDLED WITH 349 | 2.5.22 350 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Employee Directory 2 | 3 | This is a sample application demonstrating [Graphiti](https://github.com/graphiti-api/graphiti). 4 | 5 | ## Setup 6 | 7 | - Run `bin/setup`. 8 | - `rails server` 9 | - Visit `/api/v1/vandal`. 10 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::API 2 | include Graphiti::Rails::Responders 3 | end 4 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphiti-api/employee_directory/4930916e869f1f5d271d6ac9c10fd34f0f13d2b0/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/departments_controller.rb: -------------------------------------------------------------------------------- 1 | class DepartmentsController < ApplicationController 2 | def index 3 | departments = DepartmentResource.all(params) 4 | respond_with(departments) 5 | end 6 | 7 | def show 8 | department = DepartmentResource.find(params) 9 | respond_with(department) 10 | end 11 | 12 | def create 13 | department = DepartmentResource.build(params) 14 | 15 | if department.save 16 | render jsonapi: department, status: 201 17 | else 18 | render jsonapi_errors: department 19 | end 20 | end 21 | 22 | def update 23 | department = DepartmentResource.find(params) 24 | 25 | if department.update_attributes 26 | render jsonapi: department 27 | else 28 | render jsonapi_errors: department 29 | end 30 | end 31 | 32 | def destroy 33 | department = DepartmentResource.find(params) 34 | 35 | if department.destroy 36 | render jsonapi: { meta: {} }, status: 200 37 | else 38 | render jsonapi_errors: department 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/controllers/employees_controller.rb: -------------------------------------------------------------------------------- 1 | class EmployeesController < ApplicationController 2 | def index 3 | employees = EmployeeResource.all(params) 4 | respond_with(employees) 5 | end 6 | 7 | def show 8 | employee = EmployeeResource.find(params) 9 | respond_with(employee) 10 | end 11 | 12 | def create 13 | employee = EmployeeResource.build(params) 14 | 15 | if employee.save 16 | render jsonapi: employee, status: 201 17 | else 18 | render jsonapi_errors: employee 19 | end 20 | end 21 | 22 | def update 23 | employee = EmployeeResource.find(params) 24 | 25 | if employee.update_attributes 26 | render jsonapi: employee 27 | else 28 | render jsonapi_errors: employee 29 | end 30 | end 31 | 32 | def destroy 33 | employee = EmployeeResource.find(params) 34 | 35 | if employee.destroy 36 | render jsonapi: { meta: {} }, status: 200 37 | else 38 | render jsonapi_errors: employee 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/controllers/milestones_controller.rb: -------------------------------------------------------------------------------- 1 | class MilestonesController < ApplicationController 2 | def index 3 | milestones = MilestoneResource.all(params) 4 | respond_with(milestones) 5 | end 6 | 7 | def show 8 | milestone = MilestoneResource.find(params) 9 | respond_with(milestone) 10 | end 11 | 12 | def create 13 | milestone = MilestoneResource.build(params) 14 | 15 | if milestone.save 16 | render jsonapi: milestone, status: 201 17 | else 18 | render jsonapi_errors: milestone 19 | end 20 | end 21 | 22 | def update 23 | milestone = MilestoneResource.find(params) 24 | 25 | if milestone.update_attributes 26 | render jsonapi: milestone 27 | else 28 | render jsonapi_errors: milestone 29 | end 30 | end 31 | 32 | def destroy 33 | milestone = MilestoneResource.find(params) 34 | 35 | if milestone.destroy 36 | render jsonapi: { meta: {} }, status: 200 37 | else 38 | render jsonapi_errors: milestone 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/controllers/notes_controller.rb: -------------------------------------------------------------------------------- 1 | class NotesController < ApplicationController 2 | def index 3 | notes = NoteResource.all(params) 4 | respond_with(notes) 5 | end 6 | 7 | def show 8 | note = NoteResource.find(params) 9 | respond_with(note) 10 | end 11 | 12 | def create 13 | note = NoteResource.build(params) 14 | 15 | if note.save 16 | render jsonapi: note, status: 201 17 | else 18 | render jsonapi_errors: note 19 | end 20 | end 21 | 22 | def update 23 | note = NoteResource.find(params) 24 | 25 | if note.update_attributes 26 | render jsonapi: note 27 | else 28 | render jsonapi_errors: note 29 | end 30 | end 31 | 32 | def destroy 33 | note = NoteResource.find(params) 34 | 35 | if note.destroy 36 | render jsonapi: { meta: {} }, status: 200 37 | else 38 | render jsonapi_errors: note 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/controllers/positions_controller.rb: -------------------------------------------------------------------------------- 1 | class PositionsController < ApplicationController 2 | def index 3 | positions = PositionResource.all(params) 4 | respond_with(positions) 5 | end 6 | 7 | def show 8 | position = PositionResource.find(params) 9 | respond_with(position) 10 | end 11 | 12 | def create 13 | position = PositionResource.build(params) 14 | 15 | if position.save 16 | render jsonapi: position, status: 201 17 | else 18 | render jsonapi_errors: position 19 | end 20 | end 21 | 22 | def update 23 | position = PositionResource.find(params) 24 | 25 | if position.update_attributes 26 | render jsonapi: position 27 | else 28 | render jsonapi_errors: position 29 | end 30 | end 31 | 32 | def destroy 33 | position = PositionResource.find(params) 34 | 35 | if position.destroy 36 | render jsonapi: { meta: {} }, status: 200 37 | else 38 | render jsonapi_errors: position 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/controllers/tasks_controller.rb: -------------------------------------------------------------------------------- 1 | class TasksController < ApplicationController 2 | def index 3 | tasks = TaskResource.all(params) 4 | respond_with(tasks) 5 | end 6 | 7 | def show 8 | task = TaskResource.find(params) 9 | respond_with(task) 10 | end 11 | 12 | def create 13 | task = TaskResource.build(params) 14 | 15 | if task.save 16 | render jsonapi: task, status: 201 17 | else 18 | render jsonapi_errors: task 19 | end 20 | end 21 | 22 | def update 23 | task = TaskResource.find(params) 24 | 25 | if task.update_attributes 26 | render jsonapi: task 27 | else 28 | render jsonapi_errors: task 29 | end 30 | end 31 | 32 | def destroy 33 | task = TaskResource.find(params) 34 | 35 | if task.destroy 36 | render jsonapi: { meta: {} }, status: 200 37 | else 38 | render jsonapi_errors: task 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/controllers/teams_controller.rb: -------------------------------------------------------------------------------- 1 | class TeamsController < ApplicationController 2 | def index 3 | teams = TeamResource.all(params) 4 | respond_with(teams) 5 | end 6 | 7 | def show 8 | team = TeamResource.find(params) 9 | respond_with(team) 10 | end 11 | 12 | def create 13 | team = TeamResource.build(params) 14 | 15 | if team.save 16 | render jsonapi: team, status: 201 17 | else 18 | render jsonapi_errors: team 19 | end 20 | end 21 | 22 | def update 23 | team = TeamResource.find(params) 24 | 25 | if team.update_attributes 26 | render jsonapi: team 27 | else 28 | render jsonapi_errors: team 29 | end 30 | end 31 | 32 | def destroy 33 | team = TeamResource.find(params) 34 | 35 | if team.destroy 36 | render jsonapi: { meta: {} }, status: 200 37 | else 38 | render jsonapi_errors: team 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /app/models/bug.rb: -------------------------------------------------------------------------------- 1 | class Bug < Task 2 | end 3 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphiti-api/employee_directory/4930916e869f1f5d271d6ac9c10fd34f0f13d2b0/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/department.rb: -------------------------------------------------------------------------------- 1 | class Department < ApplicationRecord 2 | has_many :positions 3 | has_many :teams 4 | has_many :notes, as: :notable 5 | end 6 | -------------------------------------------------------------------------------- /app/models/employee.rb: -------------------------------------------------------------------------------- 1 | class Employee < ApplicationRecord 2 | has_many :positions 3 | has_many :team_memberships 4 | has_many :teams, through: :team_memberships 5 | has_many :notes, as: :notable 6 | has_many :tasks 7 | has_many :bugs 8 | has_many :features 9 | has_many :epics 10 | has_one :current_position, 11 | -> { current(true) }, 12 | class_name: 'Position' 13 | end 14 | -------------------------------------------------------------------------------- /app/models/epic.rb: -------------------------------------------------------------------------------- 1 | class Epic < Task 2 | has_many :milestones 3 | end 4 | -------------------------------------------------------------------------------- /app/models/feature.rb: -------------------------------------------------------------------------------- 1 | class Feature < Task 2 | end 3 | -------------------------------------------------------------------------------- /app/models/milestone.rb: -------------------------------------------------------------------------------- 1 | class Milestone < ApplicationRecord 2 | belongs_to :epic 3 | end 4 | -------------------------------------------------------------------------------- /app/models/note.rb: -------------------------------------------------------------------------------- 1 | class Note < ApplicationRecord 2 | belongs_to :notable, polymorphic: true 3 | end 4 | -------------------------------------------------------------------------------- /app/models/position.rb: -------------------------------------------------------------------------------- 1 | class Position < ApplicationRecord 2 | belongs_to :employee 3 | belongs_to :department 4 | 5 | scope :current, ->(bool) { 6 | clause = { historical_index: 1 } 7 | bool ? where(clause) : where.not(clause) 8 | } 9 | 10 | def self.reorder!(employee_id) 11 | scope = Position.where(employee_id: employee_id).order(created_at: :desc) 12 | scope.each_with_index do |p, index| 13 | p.update_attribute(:historical_index, index + 1) 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/models/task.rb: -------------------------------------------------------------------------------- 1 | class Task < ApplicationRecord 2 | TYPES = %w(Bug Feature Epic) 3 | 4 | belongs_to :team, optional: true 5 | belongs_to :employee, optional: true 6 | end 7 | -------------------------------------------------------------------------------- /app/models/team.rb: -------------------------------------------------------------------------------- 1 | class Team < ApplicationRecord 2 | belongs_to :department 3 | has_many :team_memberships 4 | has_many :employees, through: :team_memberships 5 | has_many :notes, as: :notable 6 | has_many :tasks 7 | end 8 | -------------------------------------------------------------------------------- /app/models/team_membership.rb: -------------------------------------------------------------------------------- 1 | class TeamMembership < ApplicationRecord 2 | belongs_to :team 3 | belongs_to :employee 4 | end 5 | -------------------------------------------------------------------------------- /app/resources/application_resource.rb: -------------------------------------------------------------------------------- 1 | # ApplicationResource is similar to ApplicationRecord - a base class that 2 | # holds configuration/methods for subclasses. 3 | # All Resources should inherit from ApplicationResource. 4 | class ApplicationResource < Graphiti::Resource 5 | # Use the ActiveRecord Adapter for all subclasses. 6 | # Subclasses can still override this default. 7 | self.abstract_class = true 8 | self.adapter = Graphiti::Adapters::ActiveRecord 9 | self.base_url = Rails.application.routes.default_url_options[:host] 10 | self.endpoint_namespace = '/api/v1' 11 | end 12 | -------------------------------------------------------------------------------- /app/resources/bug_resource.rb: -------------------------------------------------------------------------------- 1 | class BugResource < TaskResource 2 | end 3 | -------------------------------------------------------------------------------- /app/resources/department_resource.rb: -------------------------------------------------------------------------------- 1 | class DepartmentResource < ApplicationResource 2 | attribute :name, :string 3 | 4 | has_many :positions 5 | has_many :teams 6 | polymorphic_has_many :notes, as: :notable 7 | end 8 | -------------------------------------------------------------------------------- /app/resources/employee_resource.rb: -------------------------------------------------------------------------------- 1 | class EmployeeResource < ApplicationResource 2 | attribute :first_name, :string 3 | attribute :last_name, :string 4 | attribute :age, :integer 5 | attribute :created_at, :datetime, writable: false 6 | attribute :updated_at, :datetime, writable: false 7 | attribute :title, :string, only: [:filterable, :sortable] 8 | 9 | has_many :positions 10 | has_many :tasks 11 | many_to_many :teams 12 | polymorphic_has_many :notes, as: :notable 13 | has_one :current_position, resource: PositionResource do 14 | params do |hash| 15 | hash[:filter][:current] = true 16 | end 17 | end 18 | 19 | filter :title, only: [:eq] do 20 | eq do |scope, value| 21 | scope.joins(:current_position).merge(Position.where(title: value)) 22 | end 23 | end 24 | 25 | sort :title do |scope, value| 26 | scope.joins(:current_position).merge(Position.order(title: value)) 27 | end 28 | 29 | sort :department_name, :string do |scope, value| 30 | scope.joins(current_position: :department) 31 | .merge(Department.order(name: value)) 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /app/resources/epic_resource.rb: -------------------------------------------------------------------------------- 1 | class EpicResource < TaskResource 2 | has_many :milestones 3 | end 4 | -------------------------------------------------------------------------------- /app/resources/feature_resource.rb: -------------------------------------------------------------------------------- 1 | class FeatureResource < TaskResource 2 | attribute :points, :integer do 3 | rand(20) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/resources/milestone_resource.rb: -------------------------------------------------------------------------------- 1 | class MilestoneResource < ApplicationResource 2 | attribute :epic_id, :integer, only: [:filterable] 3 | attribute :name, :string 4 | 5 | belongs_to :epic do 6 | link do |milestone| 7 | helpers = Rails.application.routes.url_helpers 8 | helpers.task_url(milestone.epic_id) 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/resources/note_resource.rb: -------------------------------------------------------------------------------- 1 | class NoteResource < ApplicationResource 2 | attribute :notable_id, :integer, only: [:filterable] 3 | attribute :body, :string 4 | 5 | filter :notable_type, :string, allow: %w(Employee Department Team) 6 | 7 | polymorphic_belongs_to :notable do 8 | group_by(:notable_type) do 9 | on(:Employee) 10 | on(:Team) 11 | on(:Department) 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /app/resources/position_resource.rb: -------------------------------------------------------------------------------- 1 | class PositionResource < ApplicationResource 2 | attribute :employee_id, :integer, readable: false 3 | attribute :department_id, :integer, readable: false 4 | attribute :title, :string 5 | attribute :historical_index, :integer, only: [:sortable] 6 | attribute :active, :boolean 7 | 8 | belongs_to :employee 9 | belongs_to :department 10 | 11 | filter :current, :boolean do 12 | eq { |scope, value| scope.current(value) } 13 | end 14 | 15 | before_commit only: [:create, :destroy] do |position| 16 | Position.reorder!(position.employee_id) 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /app/resources/task_resource.rb: -------------------------------------------------------------------------------- 1 | class TaskResource < ApplicationResource 2 | self.polymorphic = %w(FeatureResource BugResource EpicResource) 3 | 4 | attribute :employee_id, :integer, only: [:filterable] 5 | attribute :team_id, :integer, only: [:filterable] 6 | attribute :title, :string 7 | 8 | belongs_to :employee 9 | belongs_to :team 10 | end 11 | -------------------------------------------------------------------------------- /app/resources/team_resource.rb: -------------------------------------------------------------------------------- 1 | class TeamResource < ApplicationResource 2 | attribute :department_id, :integer, only: [:filterable] 3 | attribute :name, :string 4 | 5 | belongs_to :department 6 | many_to_many :employees 7 | has_many :tasks 8 | polymorphic_has_many :notes, as: :notable 9 | end 10 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../config/application', __dir__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /bin/rspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'rspec' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "pathname" 12 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 13 | Pathname.new(__FILE__).realpath) 14 | 15 | bundle_binstub = File.expand_path("../bundle", __FILE__) 16 | 17 | if File.file?(bundle_binstub) 18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 19 | load(bundle_binstub) 20 | else 21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 23 | end 24 | end 25 | 26 | require "rubygems" 27 | require "bundler/setup" 28 | 29 | load Gem.bin_path("rspec-core", "rspec") 30 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a starting point to setup your application. 14 | # Add necessary setup steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?('config/database.yml') 22 | # cp 'config/database.yml.sample', 'config/database.yml' 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! 'bin/rails db:setup' 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! 'bin/rails log:clear tmp:clear' 30 | 31 | puts "\n== Restarting application server ==" 32 | system! 'bin/rails restart' 33 | end 34 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a way to update your development environment automatically. 14 | # Add necessary update steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | puts "\n== Updating database ==" 21 | system! 'bin/rails db:migrate' 22 | 23 | puts "\n== Removing old logs and tempfiles ==" 24 | system! 'bin/rails log:clear tmp:clear' 25 | 26 | puts "\n== Restarting application server ==" 27 | system! 'bin/rails restart' 28 | end 29 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require "rails" 4 | # Pick the frameworks you want: 5 | require "active_model/railtie" 6 | require "active_job/railtie" 7 | require "active_record/railtie" 8 | require "active_storage/engine" 9 | require "action_controller/railtie" 10 | require "action_mailer/railtie" 11 | require "action_view/railtie" 12 | require "action_cable/engine" 13 | # require "sprockets/railtie" 14 | require "rails/test_unit/railtie" 15 | 16 | # Require the gems listed in Gemfile, including any gems 17 | # you've limited to :test, :development, or :production. 18 | Bundler.require(*Rails.groups) 19 | 20 | module EmployeeDirectory 21 | class Application < Rails::Application 22 | # Initialize configuration defaults for originally generated Rails version. 23 | config.load_defaults 5.2 24 | 25 | # Settings in config/environments/* take precedence over those specified here. 26 | # Application configuration can go into files in config/initializers 27 | # -- all .rb files in that directory are automatically loaded after loading 28 | # the framework and any gems in your application. 29 | 30 | # Only loads a smaller set of middleware suitable for API only apps. 31 | # Middleware like session, flash, cookies can be added back manually. 32 | # Skip views, helpers and assets when generating a new resource. 33 | config.api_only = true 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | require 'bootsnap/setup' # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: employee_directory_production 11 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | 4InfaySX0eHuy+ZkzjnbPvAh9/Exiwu3arnNb+04r40kTPNTrjhUPFU2DJAuq8nitqcnqSktPHjYReu6Coif8NTO7ky+OupeRkwycjAoF1T933Ok8emVl9Hw7WBykH0L4yMdFceb0vkXro3hcxSTzs+tsb6s3PxVufaOc+WV1SgdFSngCkwxsAXKg3CT/nU1b54tMcJkGkX8WXn9LwFTPXP1jdX9ytdggx5HjdcWb2fYC5oehBoj2bVetwbabvwlU3wzXPwWPZ1Ad3CBPua6CTX76vd1oCBMtTP/tmUHl4iNqVOW7ajaFKlzGhO/EjbWJVc0EkWc4/IFD6NfMWbtGsIOVXIAFa2NqBe0CEdI5hWjKR2M15yNufWdqtKeTo/dNrUNa+uhdHzCN72yfnwHdTIrzV+yqVHBKFqb--ZcWnOWxGIsy5x9ID--hRwHbyT1C0aFVewFc1BIsg== -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | # Run rails dev:cache to toggle caching. 17 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 18 | config.action_controller.perform_caching = true 19 | 20 | config.cache_store = :memory_store 21 | config.public_file_server.headers = { 22 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 23 | } 24 | else 25 | config.action_controller.perform_caching = false 26 | 27 | config.cache_store = :null_store 28 | end 29 | 30 | # Store uploaded files on the local file system (see config/storage.yml for options) 31 | config.active_storage.service = :local 32 | 33 | # Don't care if the mailer can't send. 34 | config.action_mailer.raise_delivery_errors = false 35 | 36 | config.action_mailer.perform_caching = false 37 | 38 | # Print deprecation notices to the Rails logger. 39 | config.active_support.deprecation = :log 40 | 41 | # Raise an error on page load if there are pending migrations. 42 | config.active_record.migration_error = :page_load 43 | 44 | # Highlight code that triggered database queries in logs. 45 | config.active_record.verbose_query_logs = true 46 | 47 | 48 | # Raises error for missing translations 49 | # config.action_view.raise_on_missing_translations = true 50 | 51 | # Use an evented file watcher to asynchronously detect changes in source code, 52 | # routes, locales, etc. This feature depends on the listen gem. 53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 54 | end 55 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 18 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 19 | # config.require_master_key = true 20 | 21 | # Disable serving static files from the `/public` folder by default since 22 | # Apache or NGINX already handles this. 23 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 24 | 25 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 26 | # config.action_controller.asset_host = 'http://assets.example.com' 27 | 28 | # Specifies the header that your server uses for sending files. 29 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 30 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 31 | 32 | # Store uploaded files on the local file system (see config/storage.yml for options) 33 | config.active_storage.service = :local 34 | 35 | # Mount Action Cable outside main process or domain 36 | # config.action_cable.mount_path = nil 37 | # config.action_cable.url = 'wss://example.com/cable' 38 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 39 | 40 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 41 | # config.force_ssl = true 42 | 43 | # Use the lowest log level to ensure availability of diagnostic information 44 | # when problems arise. 45 | config.log_level = :debug 46 | 47 | # Prepend all log lines with the following tags. 48 | config.log_tags = [ :request_id ] 49 | 50 | # Use a different cache store in production. 51 | # config.cache_store = :mem_cache_store 52 | 53 | # Use a real queuing backend for Active Job (and separate queues per environment) 54 | # config.active_job.queue_adapter = :resque 55 | # config.active_job.queue_name_prefix = "employee_directory_#{Rails.env}" 56 | 57 | config.action_mailer.perform_caching = false 58 | 59 | # Ignore bad email addresses and do not raise email delivery errors. 60 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 61 | # config.action_mailer.raise_delivery_errors = false 62 | 63 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 64 | # the I18n.default_locale when a translation cannot be found). 65 | config.i18n.fallbacks = true 66 | 67 | # Send deprecation notices to registered listeners. 68 | config.active_support.deprecation = :notify 69 | 70 | # Use default logging formatter so that PID and timestamp are not suppressed. 71 | config.log_formatter = ::Logger::Formatter.new 72 | 73 | # Use a different logger for distributed setups. 74 | # require 'syslog/logger' 75 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 76 | 77 | if ENV["RAILS_LOG_TO_STDOUT"].present? 78 | logger = ActiveSupport::Logger.new(STDOUT) 79 | logger.formatter = config.log_formatter 80 | config.logger = ActiveSupport::TaggedLogging.new(logger) 81 | end 82 | 83 | # Do not dump schema after migrations. 84 | config.active_record.dump_schema_after_migration = false 85 | end 86 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | 31 | # Store uploaded files on the local file system in a temporary directory 32 | config.active_storage.service = :test 33 | 34 | config.action_mailer.perform_caching = false 35 | 36 | # Tell Action Mailer not to deliver emails to the real world. 37 | # The :test delivery method accumulates sent emails in the 38 | # ActionMailer::Base.deliveries array. 39 | config.action_mailer.delivery_method = :test 40 | 41 | # Print deprecation notices to the stderr. 42 | config.active_support.deprecation = :stderr 43 | 44 | # Raises error for missing translations 45 | # config.action_view.raise_on_missing_translations = true 46 | end 47 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ActiveSupport::Reloader.to_prepare do 4 | # ApplicationController.renderer.defaults.merge!( 5 | # http_host: 'example.org', 6 | # https: false 7 | # ) 8 | # end 9 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/cors.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Avoid CORS issues when API is called from the frontend app. 4 | # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. 5 | 6 | # Read more: https://github.com/cyu/rack-cors 7 | 8 | # Rails.application.config.middleware.insert_before 0, Rack::Cors do 9 | # allow do 10 | # origins 'example.com' 11 | # 12 | # resource '*', 13 | # headers: :any, 14 | # methods: [:get, :post, :put, :patch, :delete, :options, :head] 15 | # end 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at http://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the `pidfile` that Puma will use. 19 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 20 | 21 | # Specifies the number of `workers` to boot in clustered mode. 22 | # Workers are forked webserver processes. If using threads and workers together 23 | # the concurrency of the application would be max `threads` * `workers`. 24 | # Workers do not work on JRuby or Windows (both of which do not support 25 | # processes). 26 | # 27 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 28 | 29 | # Use the `preload_app!` method when specifying a `workers` number. 30 | # This directive tells Puma to first boot the application and load code 31 | # before forking the application. This takes advantage of Copy On Write 32 | # process behavior so workers use less memory. 33 | # 34 | # preload_app! 35 | 36 | # Allow puma to be restarted by `rails restart` command. 37 | plugin :tmp_restart 38 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | scope path: ApplicationResource.endpoint_namespace, defaults: { format: :jsonapi } do 3 | mount VandalUi::Engine, at: '/vandal' 4 | 5 | resources :milestones 6 | resources :tasks 7 | resources :notes 8 | resources :teams 9 | resources :departments 10 | resources :positions 11 | resources :employees 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w[ 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ].each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket 23 | 24 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /db/migrate/20180903174755_create_employees.rb: -------------------------------------------------------------------------------- 1 | class CreateEmployees < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :employees do |t| 4 | t.string :first_name 5 | t.string :last_name 6 | t.integer :age 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20180903175706_create_positions.rb: -------------------------------------------------------------------------------- 1 | class CreatePositions < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :positions do |t| 4 | t.belongs_to :employee, index: true 5 | 6 | t.string :title 7 | t.integer :historical_index 8 | t.boolean :active 9 | 10 | t.timestamps 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /db/migrate/20180904115831_create_departments.rb: -------------------------------------------------------------------------------- 1 | class CreateDepartments < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :departments do |t| 4 | t.string :name 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/20180904120042_add_department_id_to_positions.rb: -------------------------------------------------------------------------------- 1 | class AddDepartmentIdToPositions < ActiveRecord::Migration[5.2] 2 | def change 3 | add_column :positions, :department_id, :integer 4 | add_index :positions, :department_id 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20180904123419_create_teams.rb: -------------------------------------------------------------------------------- 1 | class CreateTeams < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :teams do |t| 4 | t.belongs_to :department, index: true 5 | t.string :name 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20180904123442_create_team_memberships.rb: -------------------------------------------------------------------------------- 1 | class CreateTeamMemberships < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :team_memberships do |t| 4 | t.belongs_to :team, index: true 5 | t.belongs_to :employee, index: true 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20180904141521_create_notes.rb: -------------------------------------------------------------------------------- 1 | class CreateNotes < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :notes do |t| 4 | t.references :notable, polymorphic: true, index: true 5 | t.text :body 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20180904143550_create_tasks.rb: -------------------------------------------------------------------------------- 1 | class CreateTasks < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :tasks do |t| 4 | t.belongs_to :employee, index: true 5 | t.belongs_to :team, index: true 6 | t.string :type, index: true 7 | t.string :title 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20180904143830_create_milestones.rb: -------------------------------------------------------------------------------- 1 | class CreateMilestones < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :milestones do |t| 4 | t.belongs_to :epic, index: true 5 | t.string :name 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # This file is the source Rails uses to define your schema when running `bin/rails 6 | # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to 7 | # be faster and is potentially less error prone than running all of your 8 | # migrations from scratch. Old migrations may fail to apply correctly if those 9 | # migrations use external dependencies or application code. 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema[8.0].define(version: 2018_09_04_143830) do 14 | create_table "departments", force: :cascade do |t| 15 | t.string "name" 16 | t.datetime "created_at", precision: nil, null: false 17 | t.datetime "updated_at", precision: nil, null: false 18 | end 19 | 20 | create_table "employees", force: :cascade do |t| 21 | t.string "first_name" 22 | t.string "last_name" 23 | t.integer "age" 24 | t.datetime "created_at", precision: nil, null: false 25 | t.datetime "updated_at", precision: nil, null: false 26 | end 27 | 28 | create_table "milestones", force: :cascade do |t| 29 | t.integer "epic_id" 30 | t.string "name" 31 | t.datetime "created_at", precision: nil, null: false 32 | t.datetime "updated_at", precision: nil, null: false 33 | t.index ["epic_id"], name: "index_milestones_on_epic_id" 34 | end 35 | 36 | create_table "notes", force: :cascade do |t| 37 | t.string "notable_type" 38 | t.integer "notable_id" 39 | t.text "body" 40 | t.datetime "created_at", precision: nil, null: false 41 | t.datetime "updated_at", precision: nil, null: false 42 | t.index ["notable_type", "notable_id"], name: "index_notes_on_notable_type_and_notable_id" 43 | end 44 | 45 | create_table "positions", force: :cascade do |t| 46 | t.integer "employee_id" 47 | t.string "title" 48 | t.integer "historical_index" 49 | t.boolean "active" 50 | t.datetime "created_at", precision: nil, null: false 51 | t.datetime "updated_at", precision: nil, null: false 52 | t.integer "department_id" 53 | t.index ["department_id"], name: "index_positions_on_department_id" 54 | t.index ["employee_id"], name: "index_positions_on_employee_id" 55 | end 56 | 57 | create_table "tasks", force: :cascade do |t| 58 | t.integer "employee_id" 59 | t.integer "team_id" 60 | t.string "type" 61 | t.string "title" 62 | t.datetime "created_at", precision: nil, null: false 63 | t.datetime "updated_at", precision: nil, null: false 64 | t.index ["employee_id"], name: "index_tasks_on_employee_id" 65 | t.index ["team_id"], name: "index_tasks_on_team_id" 66 | t.index ["type"], name: "index_tasks_on_type" 67 | end 68 | 69 | create_table "team_memberships", force: :cascade do |t| 70 | t.integer "team_id" 71 | t.integer "employee_id" 72 | t.datetime "created_at", precision: nil, null: false 73 | t.datetime "updated_at", precision: nil, null: false 74 | t.index ["employee_id"], name: "index_team_memberships_on_employee_id" 75 | t.index ["team_id"], name: "index_team_memberships_on_team_id" 76 | end 77 | 78 | create_table "teams", force: :cascade do |t| 79 | t.integer "department_id" 80 | t.string "name" 81 | t.datetime "created_at", precision: nil, null: false 82 | t.datetime "updated_at", precision: nil, null: false 83 | t.index ["department_id"], name: "index_teams_on_department_id" 84 | end 85 | end 86 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | [ 2 | Employee, 3 | Position, 4 | Department, 5 | TeamMembership, 6 | Team, 7 | Note, 8 | Task, 9 | Milestone 10 | ].each(&:delete_all) 11 | 12 | departments = [] 13 | def create_department(name) 14 | dept = Department.create! name: name 15 | team = dept.teams.create!(name: 'Engineering Team B') 16 | team.notes.create!(body: Faker::Lorem.sentence) 17 | dept.teams.create!(name: 'Engineering Team C') 18 | dept.notes.create!(body: Faker::Lorem.sentence) 19 | dept 20 | end 21 | 22 | departments << create_department('Engineering') 23 | departments << create_department('Safety') 24 | departments << create_department('QA') 25 | 26 | 100.times do 27 | employee = Employee.create! first_name: Faker::Name.first_name, 28 | last_name: Faker::Name.last_name, 29 | age: rand(20..80) 30 | 31 | (1..2).each do |i| 32 | employee.positions.create! title: Faker::Job.title, 33 | historical_index: i, 34 | active: i == 1, 35 | department: departments.sample 36 | end 37 | 38 | employee.teams << employee.positions[0].department.teams.sample 39 | employee.notes.create!(body: Faker::Lorem.sentence) 40 | 41 | team = employee.teams.first 42 | employee.bugs.create!(title: Faker::Lorem.sentence, team: team) 43 | employee.features.create!(title: Faker::Lorem.sentence, team: team) 44 | epic = employee.epics.create!(title: Faker::Lorem.sentence, team: team) 45 | epic.milestones.create!(name: Faker::Lorem.word.titleize) 46 | end 47 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphiti-api/employee_directory/4930916e869f1f5d271d6ac9c10fd34f0f13d2b0/lib/tasks/.keep -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphiti-api/employee_directory/4930916e869f1f5d271d6ac9c10fd34f0f13d2b0/log/.keep -------------------------------------------------------------------------------- /public/api/v1/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "resources": [ 3 | { 4 | "name": "BugResource", 5 | "type": "bugs", 6 | "description": null, 7 | "attributes": { 8 | "id": { 9 | "type": "integer_id", 10 | "readable": true, 11 | "writable": true, 12 | "description": null 13 | }, 14 | "title": { 15 | "type": "string", 16 | "readable": true, 17 | "writable": true, 18 | "description": null 19 | } 20 | }, 21 | "extra_attributes": { 22 | }, 23 | "sorts": { 24 | "id": { 25 | }, 26 | "title": { 27 | } 28 | }, 29 | "filters": { 30 | "id": { 31 | "type": "integer_id", 32 | "operators": [ 33 | "eq", 34 | "not_eq", 35 | "gt", 36 | "gte", 37 | "lt", 38 | "lte" 39 | ] 40 | }, 41 | "employee_id": { 42 | "type": "integer", 43 | "operators": [ 44 | "eq", 45 | "not_eq", 46 | "gt", 47 | "gte", 48 | "lt", 49 | "lte" 50 | ] 51 | }, 52 | "team_id": { 53 | "type": "integer", 54 | "operators": [ 55 | "eq", 56 | "not_eq", 57 | "gt", 58 | "gte", 59 | "lt", 60 | "lte" 61 | ] 62 | }, 63 | "title": { 64 | "type": "string", 65 | "operators": [ 66 | "eq", 67 | "not_eq", 68 | "eql", 69 | "not_eql", 70 | "prefix", 71 | "not_prefix", 72 | "suffix", 73 | "not_suffix", 74 | "match", 75 | "not_match" 76 | ] 77 | } 78 | }, 79 | "relationships": { 80 | "employee": { 81 | "type": "belongs_to", 82 | "description": null, 83 | "resource": "EmployeeResource" 84 | }, 85 | "team": { 86 | "type": "belongs_to", 87 | "description": null, 88 | "resource": "TeamResource" 89 | } 90 | }, 91 | "polymorphic": true, 92 | "children": [ 93 | "FeatureResource", 94 | "BugResource", 95 | "EpicResource" 96 | ] 97 | }, 98 | { 99 | "name": "DepartmentResource", 100 | "type": "departments", 101 | "description": null, 102 | "attributes": { 103 | "id": { 104 | "type": "integer_id", 105 | "readable": true, 106 | "writable": true, 107 | "description": null 108 | }, 109 | "name": { 110 | "type": "string", 111 | "readable": true, 112 | "writable": true, 113 | "description": null 114 | } 115 | }, 116 | "extra_attributes": { 117 | }, 118 | "sorts": { 119 | "id": { 120 | }, 121 | "name": { 122 | } 123 | }, 124 | "filters": { 125 | "id": { 126 | "type": "integer_id", 127 | "operators": [ 128 | "eq", 129 | "not_eq", 130 | "gt", 131 | "gte", 132 | "lt", 133 | "lte" 134 | ] 135 | }, 136 | "name": { 137 | "type": "string", 138 | "operators": [ 139 | "eq", 140 | "not_eq", 141 | "eql", 142 | "not_eql", 143 | "prefix", 144 | "not_prefix", 145 | "suffix", 146 | "not_suffix", 147 | "match", 148 | "not_match" 149 | ] 150 | } 151 | }, 152 | "relationships": { 153 | "positions": { 154 | "type": "has_many", 155 | "description": null, 156 | "resource": "PositionResource" 157 | }, 158 | "teams": { 159 | "type": "has_many", 160 | "description": null, 161 | "resource": "TeamResource" 162 | }, 163 | "notes": { 164 | "type": "has_many", 165 | "description": null, 166 | "resource": "NoteResource" 167 | } 168 | } 169 | }, 170 | { 171 | "name": "EmployeeResource", 172 | "type": "employees", 173 | "description": null, 174 | "attributes": { 175 | "id": { 176 | "type": "integer_id", 177 | "readable": true, 178 | "writable": true, 179 | "description": null 180 | }, 181 | "first_name": { 182 | "type": "string", 183 | "readable": true, 184 | "writable": true, 185 | "description": null 186 | }, 187 | "last_name": { 188 | "type": "string", 189 | "readable": true, 190 | "writable": true, 191 | "description": null 192 | }, 193 | "age": { 194 | "type": "integer", 195 | "readable": true, 196 | "writable": true, 197 | "description": null 198 | }, 199 | "created_at": { 200 | "type": "datetime", 201 | "readable": true, 202 | "writable": false, 203 | "description": null 204 | }, 205 | "updated_at": { 206 | "type": "datetime", 207 | "readable": true, 208 | "writable": false, 209 | "description": null 210 | } 211 | }, 212 | "extra_attributes": { 213 | }, 214 | "sorts": { 215 | "id": { 216 | }, 217 | "first_name": { 218 | }, 219 | "last_name": { 220 | }, 221 | "age": { 222 | }, 223 | "created_at": { 224 | }, 225 | "updated_at": { 226 | }, 227 | "title": { 228 | }, 229 | "department_name": { 230 | } 231 | }, 232 | "filters": { 233 | "id": { 234 | "type": "integer_id", 235 | "operators": [ 236 | "eq", 237 | "not_eq", 238 | "gt", 239 | "gte", 240 | "lt", 241 | "lte" 242 | ] 243 | }, 244 | "first_name": { 245 | "type": "string", 246 | "operators": [ 247 | "eq", 248 | "not_eq", 249 | "eql", 250 | "not_eql", 251 | "prefix", 252 | "not_prefix", 253 | "suffix", 254 | "not_suffix", 255 | "match", 256 | "not_match" 257 | ] 258 | }, 259 | "last_name": { 260 | "type": "string", 261 | "operators": [ 262 | "eq", 263 | "not_eq", 264 | "eql", 265 | "not_eql", 266 | "prefix", 267 | "not_prefix", 268 | "suffix", 269 | "not_suffix", 270 | "match", 271 | "not_match" 272 | ] 273 | }, 274 | "age": { 275 | "type": "integer", 276 | "operators": [ 277 | "eq", 278 | "not_eq", 279 | "gt", 280 | "gte", 281 | "lt", 282 | "lte" 283 | ] 284 | }, 285 | "created_at": { 286 | "type": "datetime", 287 | "operators": [ 288 | "eq", 289 | "not_eq", 290 | "gt", 291 | "gte", 292 | "lt", 293 | "lte" 294 | ] 295 | }, 296 | "updated_at": { 297 | "type": "datetime", 298 | "operators": [ 299 | "eq", 300 | "not_eq", 301 | "gt", 302 | "gte", 303 | "lt", 304 | "lte" 305 | ] 306 | }, 307 | "title": { 308 | "type": "string", 309 | "operators": [ 310 | "eq" 311 | ] 312 | }, 313 | "team_id": { 314 | "type": "integer_id", 315 | "operators": [ 316 | "eq", 317 | "not_eq", 318 | "gt", 319 | "gte", 320 | "lt", 321 | "lte" 322 | ] 323 | } 324 | }, 325 | "relationships": { 326 | "positions": { 327 | "type": "has_many", 328 | "description": null, 329 | "resource": "PositionResource" 330 | }, 331 | "tasks": { 332 | "type": "has_many", 333 | "description": null, 334 | "resource": "TaskResource" 335 | }, 336 | "teams": { 337 | "type": "many_to_many", 338 | "description": null, 339 | "resource": "TeamResource" 340 | }, 341 | "notes": { 342 | "type": "has_many", 343 | "description": null, 344 | "resource": "NoteResource" 345 | }, 346 | "current_position": { 347 | "type": "has_one", 348 | "description": null, 349 | "resource": "PositionResource" 350 | } 351 | } 352 | }, 353 | { 354 | "name": "EpicResource", 355 | "type": "epics", 356 | "description": null, 357 | "attributes": { 358 | "id": { 359 | "type": "integer_id", 360 | "readable": true, 361 | "writable": true, 362 | "description": null 363 | }, 364 | "title": { 365 | "type": "string", 366 | "readable": true, 367 | "writable": true, 368 | "description": null 369 | } 370 | }, 371 | "extra_attributes": { 372 | }, 373 | "sorts": { 374 | "id": { 375 | }, 376 | "title": { 377 | } 378 | }, 379 | "filters": { 380 | "id": { 381 | "type": "integer_id", 382 | "operators": [ 383 | "eq", 384 | "not_eq", 385 | "gt", 386 | "gte", 387 | "lt", 388 | "lte" 389 | ] 390 | }, 391 | "employee_id": { 392 | "type": "integer", 393 | "operators": [ 394 | "eq", 395 | "not_eq", 396 | "gt", 397 | "gte", 398 | "lt", 399 | "lte" 400 | ] 401 | }, 402 | "team_id": { 403 | "type": "integer", 404 | "operators": [ 405 | "eq", 406 | "not_eq", 407 | "gt", 408 | "gte", 409 | "lt", 410 | "lte" 411 | ] 412 | }, 413 | "title": { 414 | "type": "string", 415 | "operators": [ 416 | "eq", 417 | "not_eq", 418 | "eql", 419 | "not_eql", 420 | "prefix", 421 | "not_prefix", 422 | "suffix", 423 | "not_suffix", 424 | "match", 425 | "not_match" 426 | ] 427 | } 428 | }, 429 | "relationships": { 430 | "employee": { 431 | "type": "belongs_to", 432 | "description": null, 433 | "resource": "EmployeeResource" 434 | }, 435 | "team": { 436 | "type": "belongs_to", 437 | "description": null, 438 | "resource": "TeamResource" 439 | }, 440 | "milestones": { 441 | "type": "has_many", 442 | "description": null, 443 | "resource": "MilestoneResource" 444 | } 445 | }, 446 | "polymorphic": true, 447 | "children": [ 448 | "FeatureResource", 449 | "BugResource", 450 | "EpicResource" 451 | ] 452 | }, 453 | { 454 | "name": "FeatureResource", 455 | "type": "features", 456 | "description": null, 457 | "attributes": { 458 | "id": { 459 | "type": "integer_id", 460 | "readable": true, 461 | "writable": true, 462 | "description": null 463 | }, 464 | "title": { 465 | "type": "string", 466 | "readable": true, 467 | "writable": true, 468 | "description": null 469 | }, 470 | "points": { 471 | "type": "integer", 472 | "readable": true, 473 | "writable": true, 474 | "description": null 475 | } 476 | }, 477 | "extra_attributes": { 478 | }, 479 | "sorts": { 480 | "id": { 481 | }, 482 | "title": { 483 | }, 484 | "points": { 485 | } 486 | }, 487 | "filters": { 488 | "id": { 489 | "type": "integer_id", 490 | "operators": [ 491 | "eq", 492 | "not_eq", 493 | "gt", 494 | "gte", 495 | "lt", 496 | "lte" 497 | ] 498 | }, 499 | "employee_id": { 500 | "type": "integer", 501 | "operators": [ 502 | "eq", 503 | "not_eq", 504 | "gt", 505 | "gte", 506 | "lt", 507 | "lte" 508 | ] 509 | }, 510 | "team_id": { 511 | "type": "integer", 512 | "operators": [ 513 | "eq", 514 | "not_eq", 515 | "gt", 516 | "gte", 517 | "lt", 518 | "lte" 519 | ] 520 | }, 521 | "title": { 522 | "type": "string", 523 | "operators": [ 524 | "eq", 525 | "not_eq", 526 | "eql", 527 | "not_eql", 528 | "prefix", 529 | "not_prefix", 530 | "suffix", 531 | "not_suffix", 532 | "match", 533 | "not_match" 534 | ] 535 | }, 536 | "points": { 537 | "type": "integer", 538 | "operators": [ 539 | "eq", 540 | "not_eq", 541 | "gt", 542 | "gte", 543 | "lt", 544 | "lte" 545 | ] 546 | } 547 | }, 548 | "relationships": { 549 | "employee": { 550 | "type": "belongs_to", 551 | "description": null, 552 | "resource": "EmployeeResource" 553 | }, 554 | "team": { 555 | "type": "belongs_to", 556 | "description": null, 557 | "resource": "TeamResource" 558 | } 559 | }, 560 | "polymorphic": true, 561 | "children": [ 562 | "FeatureResource", 563 | "BugResource", 564 | "EpicResource" 565 | ] 566 | }, 567 | { 568 | "name": "MilestoneResource", 569 | "type": "milestones", 570 | "description": null, 571 | "attributes": { 572 | "id": { 573 | "type": "integer_id", 574 | "readable": true, 575 | "writable": true, 576 | "description": null 577 | }, 578 | "name": { 579 | "type": "string", 580 | "readable": true, 581 | "writable": true, 582 | "description": null 583 | } 584 | }, 585 | "extra_attributes": { 586 | }, 587 | "sorts": { 588 | "id": { 589 | }, 590 | "name": { 591 | } 592 | }, 593 | "filters": { 594 | "id": { 595 | "type": "integer_id", 596 | "operators": [ 597 | "eq", 598 | "not_eq", 599 | "gt", 600 | "gte", 601 | "lt", 602 | "lte" 603 | ] 604 | }, 605 | "epic_id": { 606 | "type": "integer", 607 | "operators": [ 608 | "eq", 609 | "not_eq", 610 | "gt", 611 | "gte", 612 | "lt", 613 | "lte" 614 | ] 615 | }, 616 | "name": { 617 | "type": "string", 618 | "operators": [ 619 | "eq", 620 | "not_eq", 621 | "eql", 622 | "not_eql", 623 | "prefix", 624 | "not_prefix", 625 | "suffix", 626 | "not_suffix", 627 | "match", 628 | "not_match" 629 | ] 630 | } 631 | }, 632 | "relationships": { 633 | "epic": { 634 | "type": "belongs_to", 635 | "description": null, 636 | "resource": "EpicResource" 637 | } 638 | } 639 | }, 640 | { 641 | "name": "NoteResource", 642 | "type": "notes", 643 | "description": null, 644 | "attributes": { 645 | "id": { 646 | "type": "integer_id", 647 | "readable": true, 648 | "writable": true, 649 | "description": null 650 | }, 651 | "body": { 652 | "type": "string", 653 | "readable": true, 654 | "writable": true, 655 | "description": null 656 | } 657 | }, 658 | "extra_attributes": { 659 | }, 660 | "sorts": { 661 | "id": { 662 | }, 663 | "body": { 664 | } 665 | }, 666 | "filters": { 667 | "id": { 668 | "type": "integer_id", 669 | "operators": [ 670 | "eq", 671 | "not_eq", 672 | "gt", 673 | "gte", 674 | "lt", 675 | "lte" 676 | ] 677 | }, 678 | "notable_id": { 679 | "type": "integer", 680 | "operators": [ 681 | "eq", 682 | "not_eq", 683 | "gt", 684 | "gte", 685 | "lt", 686 | "lte" 687 | ] 688 | }, 689 | "body": { 690 | "type": "string", 691 | "operators": [ 692 | "eq", 693 | "not_eq", 694 | "eql", 695 | "not_eql", 696 | "prefix", 697 | "not_prefix", 698 | "suffix", 699 | "not_suffix", 700 | "match", 701 | "not_match" 702 | ] 703 | }, 704 | "notable_type": { 705 | "type": "string", 706 | "operators": [ 707 | "eq", 708 | "not_eq", 709 | "eql", 710 | "not_eql", 711 | "prefix", 712 | "not_prefix", 713 | "suffix", 714 | "not_suffix", 715 | "match", 716 | "not_match" 717 | ], 718 | "allow": [ 719 | "Employee", 720 | "Department", 721 | "Team" 722 | ] 723 | } 724 | }, 725 | "relationships": { 726 | "notable": { 727 | "type": "polymorphic_belongs_to", 728 | "description": null, 729 | "resources": [ 730 | "EmployeeResource", 731 | "TeamResource", 732 | "DepartmentResource" 733 | ] 734 | } 735 | } 736 | }, 737 | { 738 | "name": "PositionResource", 739 | "type": "positions", 740 | "description": null, 741 | "attributes": { 742 | "id": { 743 | "type": "integer_id", 744 | "readable": true, 745 | "writable": true, 746 | "description": null 747 | }, 748 | "employee_id": { 749 | "type": "integer", 750 | "readable": false, 751 | "writable": true, 752 | "description": null 753 | }, 754 | "department_id": { 755 | "type": "integer", 756 | "readable": false, 757 | "writable": true, 758 | "description": null 759 | }, 760 | "title": { 761 | "type": "string", 762 | "readable": true, 763 | "writable": true, 764 | "description": null 765 | }, 766 | "active": { 767 | "type": "boolean", 768 | "readable": true, 769 | "writable": true, 770 | "description": null 771 | } 772 | }, 773 | "extra_attributes": { 774 | }, 775 | "sorts": { 776 | "id": { 777 | }, 778 | "employee_id": { 779 | }, 780 | "department_id": { 781 | }, 782 | "title": { 783 | }, 784 | "historical_index": { 785 | }, 786 | "active": { 787 | } 788 | }, 789 | "filters": { 790 | "id": { 791 | "type": "integer_id", 792 | "operators": [ 793 | "eq", 794 | "not_eq", 795 | "gt", 796 | "gte", 797 | "lt", 798 | "lte" 799 | ] 800 | }, 801 | "employee_id": { 802 | "type": "integer", 803 | "operators": [ 804 | "eq", 805 | "not_eq", 806 | "gt", 807 | "gte", 808 | "lt", 809 | "lte" 810 | ] 811 | }, 812 | "department_id": { 813 | "type": "integer", 814 | "operators": [ 815 | "eq", 816 | "not_eq", 817 | "gt", 818 | "gte", 819 | "lt", 820 | "lte" 821 | ] 822 | }, 823 | "title": { 824 | "type": "string", 825 | "operators": [ 826 | "eq", 827 | "not_eq", 828 | "eql", 829 | "not_eql", 830 | "prefix", 831 | "not_prefix", 832 | "suffix", 833 | "not_suffix", 834 | "match", 835 | "not_match" 836 | ] 837 | }, 838 | "active": { 839 | "type": "boolean", 840 | "operators": [ 841 | "eq" 842 | ], 843 | "single": true 844 | }, 845 | "current": { 846 | "type": "boolean", 847 | "operators": [ 848 | "eq" 849 | ], 850 | "single": true 851 | } 852 | }, 853 | "relationships": { 854 | "employee": { 855 | "type": "belongs_to", 856 | "description": null, 857 | "resource": "EmployeeResource" 858 | }, 859 | "department": { 860 | "type": "belongs_to", 861 | "description": null, 862 | "resource": "DepartmentResource" 863 | } 864 | } 865 | }, 866 | { 867 | "name": "TaskResource", 868 | "type": "tasks", 869 | "description": null, 870 | "attributes": { 871 | "id": { 872 | "type": "integer_id", 873 | "readable": true, 874 | "writable": true, 875 | "description": null 876 | }, 877 | "title": { 878 | "type": "string", 879 | "readable": true, 880 | "writable": true, 881 | "description": null 882 | } 883 | }, 884 | "extra_attributes": { 885 | }, 886 | "sorts": { 887 | "id": { 888 | }, 889 | "title": { 890 | } 891 | }, 892 | "filters": { 893 | "id": { 894 | "type": "integer_id", 895 | "operators": [ 896 | "eq", 897 | "not_eq", 898 | "gt", 899 | "gte", 900 | "lt", 901 | "lte" 902 | ] 903 | }, 904 | "employee_id": { 905 | "type": "integer", 906 | "operators": [ 907 | "eq", 908 | "not_eq", 909 | "gt", 910 | "gte", 911 | "lt", 912 | "lte" 913 | ] 914 | }, 915 | "team_id": { 916 | "type": "integer", 917 | "operators": [ 918 | "eq", 919 | "not_eq", 920 | "gt", 921 | "gte", 922 | "lt", 923 | "lte" 924 | ] 925 | }, 926 | "title": { 927 | "type": "string", 928 | "operators": [ 929 | "eq", 930 | "not_eq", 931 | "eql", 932 | "not_eql", 933 | "prefix", 934 | "not_prefix", 935 | "suffix", 936 | "not_suffix", 937 | "match", 938 | "not_match" 939 | ] 940 | } 941 | }, 942 | "relationships": { 943 | "employee": { 944 | "type": "belongs_to", 945 | "description": null, 946 | "resource": "EmployeeResource" 947 | }, 948 | "team": { 949 | "type": "belongs_to", 950 | "description": null, 951 | "resource": "TeamResource" 952 | } 953 | }, 954 | "polymorphic": true, 955 | "children": [ 956 | "FeatureResource", 957 | "BugResource", 958 | "EpicResource" 959 | ] 960 | }, 961 | { 962 | "name": "TeamResource", 963 | "type": "teams", 964 | "description": null, 965 | "attributes": { 966 | "id": { 967 | "type": "integer_id", 968 | "readable": true, 969 | "writable": true, 970 | "description": null 971 | }, 972 | "name": { 973 | "type": "string", 974 | "readable": true, 975 | "writable": true, 976 | "description": null 977 | } 978 | }, 979 | "extra_attributes": { 980 | }, 981 | "sorts": { 982 | "id": { 983 | }, 984 | "name": { 985 | } 986 | }, 987 | "filters": { 988 | "id": { 989 | "type": "integer_id", 990 | "operators": [ 991 | "eq", 992 | "not_eq", 993 | "gt", 994 | "gte", 995 | "lt", 996 | "lte" 997 | ] 998 | }, 999 | "department_id": { 1000 | "type": "integer", 1001 | "operators": [ 1002 | "eq", 1003 | "not_eq", 1004 | "gt", 1005 | "gte", 1006 | "lt", 1007 | "lte" 1008 | ] 1009 | }, 1010 | "name": { 1011 | "type": "string", 1012 | "operators": [ 1013 | "eq", 1014 | "not_eq", 1015 | "eql", 1016 | "not_eql", 1017 | "prefix", 1018 | "not_prefix", 1019 | "suffix", 1020 | "not_suffix", 1021 | "match", 1022 | "not_match" 1023 | ] 1024 | }, 1025 | "employee_id": { 1026 | "type": "integer_id", 1027 | "operators": [ 1028 | "eq", 1029 | "not_eq", 1030 | "gt", 1031 | "gte", 1032 | "lt", 1033 | "lte" 1034 | ] 1035 | } 1036 | }, 1037 | "relationships": { 1038 | "department": { 1039 | "type": "belongs_to", 1040 | "description": null, 1041 | "resource": "DepartmentResource" 1042 | }, 1043 | "employees": { 1044 | "type": "many_to_many", 1045 | "description": null, 1046 | "resource": "EmployeeResource" 1047 | }, 1048 | "tasks": { 1049 | "type": "has_many", 1050 | "description": null, 1051 | "resource": "TaskResource" 1052 | }, 1053 | "notes": { 1054 | "type": "has_many", 1055 | "description": null, 1056 | "resource": "NoteResource" 1057 | } 1058 | } 1059 | } 1060 | ], 1061 | "endpoints": { 1062 | "/api/v1/departments": { 1063 | "actions": { 1064 | "index": { 1065 | "resource": "DepartmentResource" 1066 | }, 1067 | "show": { 1068 | "resource": "DepartmentResource" 1069 | }, 1070 | "create": { 1071 | "resource": "DepartmentResource" 1072 | }, 1073 | "update": { 1074 | "resource": "DepartmentResource" 1075 | }, 1076 | "destroy": { 1077 | "resource": "DepartmentResource" 1078 | } 1079 | } 1080 | }, 1081 | "/api/v1/employees": { 1082 | "actions": { 1083 | "index": { 1084 | "resource": "EmployeeResource" 1085 | }, 1086 | "show": { 1087 | "resource": "EmployeeResource" 1088 | }, 1089 | "create": { 1090 | "resource": "EmployeeResource" 1091 | }, 1092 | "update": { 1093 | "resource": "EmployeeResource" 1094 | }, 1095 | "destroy": { 1096 | "resource": "EmployeeResource" 1097 | } 1098 | } 1099 | }, 1100 | "/api/v1/milestones": { 1101 | "actions": { 1102 | "index": { 1103 | "resource": "MilestoneResource" 1104 | }, 1105 | "show": { 1106 | "resource": "MilestoneResource" 1107 | }, 1108 | "create": { 1109 | "resource": "MilestoneResource" 1110 | }, 1111 | "update": { 1112 | "resource": "MilestoneResource" 1113 | }, 1114 | "destroy": { 1115 | "resource": "MilestoneResource" 1116 | } 1117 | } 1118 | }, 1119 | "/api/v1/notes": { 1120 | "actions": { 1121 | "index": { 1122 | "resource": "NoteResource" 1123 | }, 1124 | "show": { 1125 | "resource": "NoteResource" 1126 | }, 1127 | "create": { 1128 | "resource": "NoteResource" 1129 | }, 1130 | "update": { 1131 | "resource": "NoteResource" 1132 | }, 1133 | "destroy": { 1134 | "resource": "NoteResource" 1135 | } 1136 | } 1137 | }, 1138 | "/api/v1/positions": { 1139 | "actions": { 1140 | "index": { 1141 | "resource": "PositionResource" 1142 | }, 1143 | "show": { 1144 | "resource": "PositionResource" 1145 | }, 1146 | "create": { 1147 | "resource": "PositionResource" 1148 | }, 1149 | "update": { 1150 | "resource": "PositionResource" 1151 | }, 1152 | "destroy": { 1153 | "resource": "PositionResource" 1154 | } 1155 | } 1156 | }, 1157 | "/api/v1/tasks": { 1158 | "actions": { 1159 | "index": { 1160 | "resource": "TaskResource" 1161 | }, 1162 | "show": { 1163 | "resource": "TaskResource" 1164 | }, 1165 | "create": { 1166 | "resource": "TaskResource" 1167 | }, 1168 | "update": { 1169 | "resource": "TaskResource" 1170 | }, 1171 | "destroy": { 1172 | "resource": "TaskResource" 1173 | } 1174 | } 1175 | }, 1176 | "/api/v1/teams": { 1177 | "actions": { 1178 | "index": { 1179 | "resource": "TeamResource" 1180 | }, 1181 | "show": { 1182 | "resource": "TeamResource" 1183 | }, 1184 | "create": { 1185 | "resource": "TeamResource" 1186 | }, 1187 | "update": { 1188 | "resource": "TeamResource" 1189 | }, 1190 | "destroy": { 1191 | "resource": "TeamResource" 1192 | } 1193 | } 1194 | } 1195 | }, 1196 | "types": { 1197 | "integer_id": { 1198 | "kind": "scalar", 1199 | "description": "Base Type. Query/persist as integer, render as string." 1200 | }, 1201 | "uuid": { 1202 | "kind": "scalar", 1203 | "description": "Base Type. Like a normal string, but by default only eq/!eq and case-sensitive." 1204 | }, 1205 | "string_enum": { 1206 | "kind": "scalar", 1207 | "description": "String enum type. Like a normal string, but only eq/!eq and case-sensitive. Limited to only the allowed values." 1208 | }, 1209 | "integer_enum": { 1210 | "kind": "scalar", 1211 | "description": "Integer enum type. Like a normal integer, but only eq/!eq filters. Limited to only the allowed values." 1212 | }, 1213 | "string": { 1214 | "kind": "scalar", 1215 | "description": "Base Type." 1216 | }, 1217 | "integer": { 1218 | "kind": "scalar", 1219 | "description": "Base Type." 1220 | }, 1221 | "big_decimal": { 1222 | "kind": "scalar", 1223 | "description": "Base Type." 1224 | }, 1225 | "float": { 1226 | "kind": "scalar", 1227 | "description": "Base Type." 1228 | }, 1229 | "boolean": { 1230 | "kind": "scalar", 1231 | "description": "Base Type." 1232 | }, 1233 | "date": { 1234 | "kind": "scalar", 1235 | "description": "Base Type." 1236 | }, 1237 | "datetime": { 1238 | "kind": "scalar", 1239 | "description": "Base Type." 1240 | }, 1241 | "hash": { 1242 | "kind": "record", 1243 | "description": "Base Type." 1244 | }, 1245 | "array": { 1246 | "kind": "array", 1247 | "description": "Base Type." 1248 | }, 1249 | "array_of_integer_ids": { 1250 | "kind": "array", 1251 | "description": "Base Type." 1252 | }, 1253 | "array_of_uuids": { 1254 | "kind": "array", 1255 | "description": "Base Type." 1256 | }, 1257 | "array_of_string_enums": { 1258 | "kind": "array", 1259 | "description": "Base Type." 1260 | }, 1261 | "array_of_integer_enums": { 1262 | "kind": "array", 1263 | "description": "Base Type." 1264 | }, 1265 | "array_of_strings": { 1266 | "kind": "array", 1267 | "description": "Base Type." 1268 | }, 1269 | "array_of_integers": { 1270 | "kind": "array", 1271 | "description": "Base Type." 1272 | }, 1273 | "array_of_big_decimals": { 1274 | "kind": "array", 1275 | "description": "Base Type." 1276 | }, 1277 | "array_of_floats": { 1278 | "kind": "array", 1279 | "description": "Base Type." 1280 | }, 1281 | "array_of_dates": { 1282 | "kind": "array", 1283 | "description": "Base Type." 1284 | }, 1285 | "array_of_datetimes": { 1286 | "kind": "array", 1287 | "description": "Base Type." 1288 | } 1289 | } 1290 | } -------------------------------------------------------------------------------- /public/api/v1/vandal/assets/img/squares.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphiti-api/employee_directory/4930916e869f1f5d271d6ac9c10fd34f0f13d2b0/public/api/v1/vandal/assets/img/squares.png -------------------------------------------------------------------------------- /public/api/v1/vandal/css/chunk-vendors.e6a6ca22.css: -------------------------------------------------------------------------------- 1 | .hljs{display:block;overflow-x:auto;padding:.5em;background:#f0f0f0}.hljs,.hljs-subst{color:#444}.hljs-comment{color:#888}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#bc6060}.hljs-literal{color:#78a960}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700} -------------------------------------------------------------------------------- /public/api/v1/vandal/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphiti-api/employee_directory/4930916e869f1f5d271d6ac9c10fd34f0f13d2b0/public/api/v1/vandal/favicon.ico -------------------------------------------------------------------------------- /public/api/v1/vandal/index.html: -------------------------------------------------------------------------------- 1 | vandal
4 | -------------------------------------------------------------------------------- /public/api/v1/vandal/js/app.d38ac258.js: -------------------------------------------------------------------------------- 1 | (function(e){function t(t){for(var i,r,o=t[0],c=t[1],l=t[2],h=0,d=[];h0&&i.push("".concat(a,"=").concat(n.join(","))):"object"===Object(j["a"])(n)?i.push(e(n,a)):i.push("".concat(a,"=").concat(n)))}return i=i.filter(function(e){return!!e}),i.join("&")},w=(s("55dd"),s("6b54"),function(e,t){Object.keys(e).forEach(function(s){var i=e[s];t(s,i)})}),k=function(){function e(t,s,i,a,n){Object(v["a"])(this,e),this.schema=t,this.resource=s,this.selectedRow=null,this.json=i,this.includeHash=n,this._buildRows(a),this._buildRelationships(),this._buildHeaders(),this._buildCSS()}return Object(m["a"])(e,[{key:"formattedJSON",value:function(){var e={},t=this.rows;return this.selectedRow&&(t=[this.selectedRow]),t=t.map(function(e){var t={};return w(e.attrs,function(e,s){t[e]=s.value}),w(e.relationships,function(e,s){t[e]=s.formattedJSON().data}),t}),e.data=t,e}},{key:"_buildRows",value:function(e){var t=this;Array.isArray(e)||(e=[e]),this.rows=e.map(function(e){return t.buildRow(t.resource,e)})}},{key:"_buildHeaders",value:function(){var e=[];this.rows.length>0&&this.rows.forEach(function(t){Object.keys(t.attrs).forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),this.headers=e}},{key:"_buildCSS",value:function(){var e=this.rows.map(function(e){return e.attrs.id.value.toString().length}),t=e.sort()[e.length-1];this.css="columns-".concat(this.headers.length," id-length-").concat(t)}},{key:"_resourceAttributes",value:function(){var e=this;if(this.resource.polymorphic){var t=this.resource.attributes;return this.resource.children.forEach(function(s){var i=e.schema.getResource(s);t=Object.assign({},t,i.attributes)}),t}return this.resource.attributes}},{key:"_resourceRelationships",value:function(){var e=this;if(this.resource.polymorphic){var t=this.resource.relationships||{};return this.resource.children.forEach(function(s){var i=e.schema.getResource(s);t=Object.assign({},t,i.relationships)}),t}return this.resource.relationships}},{key:"_buildRowAttributes",value:function(e,t){var s=this,i={id:{value:t.id,type:this._resourceAttributes().id.type}};return e.polymorphic&&(i._type={value:t.type,type:"string"}),w(t.attributes,function(e,t){var a=s._resourceAttributes()[e].type,n=Object(y["a"])({},e,{value:t,type:a});Object.assign(i,n)}),i}},{key:"_buildRelationshipNode",value:function(e){var t=this.json.data;Array.isArray(t)||(t=[t]),t=t.concat(this.json.included);var s=t.filter(function(t){return t.type===e.type&&t.id===e.id})[0];return s}},{key:"_eachRelationship",value:function(e,t,s){var i=this,a=t.relationships||{};w(a,function(e,t){var a=i.includeHash[e];if(a){var n=i._resourceRelationships()[e],r=i.schema.json.resources.filter(function(e){return e.name===n.resource})[0];"polymorphic_belongs_to"===n.type&&(r={polymorphic:!0,children:n.resources});var o=t.data,c=[];o?(Array.isArray(o)||(o=[o]),o.forEach(function(e){c.push(i._buildRelationshipNode(e))}),s(e,r,c,a)):s(e,r,[])}})}},{key:"_buildRelationships",value:function(){var t=this;this.rows.forEach(function(s){s.relationships={},t._eachRelationship(s.schemaResource,s.jsonResource,function(i,a,n,r){s.relationships[i]=new e(t.schema,a,t.json,n,r)}),s.hasRelationships=Object.keys(s.relationships).length>0})}},{key:"buildRow",value:function(e,t){var s=this._buildRowAttributes(e,t),i={attrs:s,schemaResource:e,jsonResource:t};return i}}]),e}(),R=s("c1df"),q=s.n(R),C=function(){function e(t,s,i,a){Object(v["a"])(this,e),this.resource=s,this.endpoint=i,this.ready=!1,this.sorts=[{name:null,dir:"asc"}],this.filters=[{name:null,operator:"eq",error:null}],this.data={},this.headers=[],this.url=null,this.urlWithDomain=null,this.page={},this.relationships={},this.fields={},this.relationshipPath=a,this.editingRelationship=!1,this.schema=t,this.endpointIdParam=null,this.error=null,this.hasRawError=!1,this.possibleRelationships=this.derivePossibleRelationships(),this.isShowRoute()&&(this.filters=[{name:"id",operator:"eq",required:!0,error:null}])}return Object(m["a"])(e,[{key:"derivePossibleRelationships",value:function(){var e=this;if(this.resource.polymorphic){var t=Object.assign({},this.resource.relationships);return this.resource.children.forEach(function(s){var i=e.schema.getResource(s);Object.assign(t,i.relationships)}),t}return this.resource.relationships}},{key:"isShowRoute",value:function(){return this.endpoint&&this.endpoint.includes("#show")}},{key:"hasFilterValue",value:function(e){var t=this.filters.filter(function(t){return t.name===e})[0];return!(!t||!t.value)}},{key:"generateParams",value:function(){var e={};return Object.assign(e,{filter:this.filterParams()}),Object.assign(e,{sort:this.sortParams().join(",")}),Object.assign(e,{page:this.paginationParams()}),Object.assign(e,{include:this.includes().join(",")}),Object.assign(e,{fields:this.fieldParams()}),e}},{key:"generateUrl",value:function(){var e=this.generateParams(),t=this.endpoint.split("#"),s=Object(p["a"])(t,2),i=s[0],a=(s[1],_(e));return this.endpointIdParam&&(i="".concat(i,"/").concat(this.endpointIdParam)),a.length>0&&(i="".concat(i,"?").concat(a)),i}},{key:"generateCurl",value:function(){var e=this.urlWithDomain,t=e.split("?"),s=Object(p["a"])(t,2),i=s[0],a=s[1];return e=i,"undefined"!=a&&(e="".concat(e,"?").concat(a)),"curl -g -H 'Content-Type: application/json' '".concat(e,"'")}},{key:"fire",value:function(){var e=Object(f["a"])(regeneratorRuntime.mark(function e(){var t,s,i,a,n;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return this.url=this.generateUrl(),this.urlWithDomain="".concat(window.location.origin).concat(this.url),t=new Headers,t.append("pragma","no-cache"),t.append("cache-control","no-cache"),{method:"GET",headers:t},s=new Request(this.url),e.next=9,fetch(s);case 9:return e.next=11,e.sent.json();case 11:this.json=e.sent,this.ready=!0,this.hasRawError=!1,this.error=null,this.json.errors?(i=this.json.errors[0],a=i.detail,n=i.meta.__raw_error__,n&&(a=n.message,this.hasRawError=!0),this.error=a):this.data=new k(this.schema,this.resource,this.json,this.json.data,this.includeHash());case 16:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"filterParams",value:function(){var e=this,t={};return this.filters.forEach(function(s){if(s.name)if("id"===s.name&&e.isShowRoute())e.endpointIdParam=s.value;else{var i={};"datetime"===e.resource.filters[s.name].type?i[s.operator]=q()(s.value,"M/D/YYYY h:mma").toISOString():i[s.operator]=s.value;var a=s.name;e.relationshipPath&&(a="".concat(e.relationshipPath,".").concat(a)),t[a]=i}}),Object.keys(this.relationships).forEach(function(s){var i=e.relationships[s],a=i.filterParams();Object.assign(t,a)}),t}},{key:"sortParams",value:function(){var e=this,t=[];return this.sorts.forEach(function(s){if(s.name){var i=s.name;e.relationshipPath&&(i="".concat(e.relationshipPath,".").concat(i)),"desc"==s.dir&&(i="-".concat(i)),t.push(i)}}),Object.keys(this.relationships).forEach(function(s){var i=e.relationships[s];i.sortParams().forEach(function(e){t.push(e)})}),t}},{key:"paginationParams",value:function(){var e=this,t={};return Object.keys(this.page).forEach(function(s){var i=s;e.relationshipPath&&(i="".concat(e.relationshipPath,".").concat(i)),t[i]=e.page[s]}),Object.keys(this.relationships).forEach(function(s){var i=e.relationships[s];Object.assign(t,i.paginationParams())}),t}},{key:"includes",value:function(){var e=this,t=[];return Object.keys(this.relationships).forEach(function(s){var i=e.relationships[s];i.includes().forEach(function(e){t.push(e)})}),0===t.length&&t.push(this.relationshipPath),t}},{key:"includeHash",value:function(){var e={};return this.includes().forEach(function(t){if(t){var s=t.split(".").reverse(),i=Object(g["a"])(s),a=i[0],n=i.slice(1);Object.assign(e,n.reduce(function(e,t){return Object(y["a"])({},t,e)},Object(y["a"])({},a,{})))}}),e}},{key:"fieldParams",value:function(){var e=this,t={},s=Object.keys(this.fields);return s.length>0&&(t[this.resource.type]=s.join(",")),Object.keys(this.relationships).forEach(function(s){var i=e.relationships[s];Object.assign(t,i.fieldParams())}),t}}]),e}(),O=function(){var e,t=this,s=t.$createElement,i=t._self._c||s;return i("div",{staticClass:"resource-form"},[i("form",{staticClass:"config",on:{submit:function(e){e.preventDefault(),t.$emit("submit")}}},[t.isRelationship?t._e():i("button",{staticClass:"btn btn-primary",staticStyle:{display:"none"},attrs:{type:"hidden"}},[t._v("Submit")]),i("div",{staticClass:"query-inputs",class:{hide:t.query.editingRelationship}},[i("div",{staticClass:"section filters first form-group"},[i("label",[t._v("Filters")]),i("a",{staticClass:"add",on:{click:t.addFilter}},[t._v("Add +")]),i("transition-group",{attrs:{name:"form-input-section"}},t._l(t.query.filters,function(e,s){return i("div",{key:s,staticClass:"form-group filter",class:{error:e.error}},[i("div",{staticClass:"clearfix form-group"},[i("select",{directives:[{name:"model",rawName:"v-model",value:e.name,expression:"filter.name"}],staticClass:"filter-name col-8 float-left form-control",on:{change:function(s){var i=Array.prototype.filter.call(s.target.options,function(e){return e.selected}).map(function(e){var t="_value"in e?e._value:e.value;return t});t.$set(e,"name",s.target.multiple?i:i[0])}}},[i("option",{attrs:{disabled:"",value:"null"}},[t._v("Choose")]),t._l(t.query.resource.filters,function(e,s){return i("option",{key:s},[t._v("\n "+t._s(s)+"\n ")])})],2),e.name?i("select",{directives:[{name:"model",rawName:"v-model",value:e.operator,expression:"filter.operator"}],staticClass:"col-3 float-left form-control",on:{change:function(s){var i=Array.prototype.filter.call(s.target.options,function(e){return e.selected}).map(function(e){var t="_value"in e?e._value:e.value;return t});t.$set(e,"operator",s.target.multiple?i:i[0])}}},t._l(t.query.resource.filters[e.name].operators,function(e){return i("option",{key:e},[t._v("\n "+t._s(e)+"\n ")])})):i("select",{staticClass:"col-3 float-left form-control"},[i("option",{attrs:{selected:"",disabled:""}},[t._v("eq")])])]),i("div",{staticClass:"clearfix"},[e.name&&"boolean"===t.query.resource.filters[e.name].type?i("div",{staticClass:"boolean-toggle"},[i("input",{directives:[{name:"model",rawName:"v-model",value:e.value,expression:"filter.value"}],staticClass:"ios-toggle",attrs:{type:"checkbox",name:e.name,id:e.name},domProps:{checked:Array.isArray(e.value)?t._i(e.value,null)>-1:e.value},on:{change:function(s){var i=e.value,a=s.target,n=!!a.checked;if(Array.isArray(i)){var r=null,o=t._i(i,r);a.checked?o<0&&t.$set(e,"value",i.concat([r])):o>-1&&t.$set(e,"value",i.slice(0,o).concat(i.slice(o+1)))}else t.$set(e,"value",n)}}}),i("label",{staticClass:"checkbox-label",attrs:{for:e.name,"data-off":"off","data-on":"on"}})]):e.name&&t.query.resource.filters[e.name].allow?i("div",[i("select",{directives:[{name:"model",rawName:"v-model",value:e.value,expression:"filter.value"}],staticClass:"filter-value form-control col-10 float-left",on:{change:function(s){var i=Array.prototype.filter.call(s.target.options,function(e){return e.selected}).map(function(e){var t="_value"in e?e._value:e.value;return t});t.$set(e,"value",s.target.multiple?i:i[0])}}},[i("option",{attrs:{disabled:"",value:"undefined"}},[t._v("Choose")]),t._l(t.query.resource.filters[e.name].allow,function(e){return i("option",{key:e},[t._v("\n "+t._s(e)+"\n ")])})],2)]):e.name&&"date"===t.query.resource.filters[e.name].type?i("div",[i("input",{directives:[{name:"model",rawName:"v-model",value:e.value,expression:"filter.value"}],staticClass:"filter-value float-left col-10 form-control",attrs:{type:"text",placeholder:"M/D/YYYY"},domProps:{value:e.value},on:{input:function(s){s.target.composing||t.$set(e,"value",s.target.value)}}})]):e.name&&"datetime"===t.query.resource.filters[e.name].type?i("div",[i("input",{directives:[{name:"model",rawName:"v-model",value:e.value,expression:"filter.value"}],staticClass:"filter-value float-left col-10 form-control",attrs:{type:"text",placeholder:"M/D/YYYY h:mma"},domProps:{value:e.value},on:{input:function(s){s.target.composing||t.$set(e,"value",s.target.value)}}})]):i("div",[i("input",{directives:[{name:"model",rawName:"v-model",value:e.value,expression:"filter.value"}],staticClass:"filter-value float-left col-10 form-control",attrs:{type:"text",placeholder:"Enter Filter Value Here"},domProps:{value:e.value},on:{input:function(s){s.target.composing||t.$set(e,"value",s.target.value)}}})]),i("a",{staticClass:"remove col-1",on:{click:function(s){t.removeFilter(e)}}},[t._v("x")])]),e.required?i("div",{staticClass:"required-filter text-muted"},[t._v("\n Required\n ")]):t._e()])}))],1),i("div",{staticClass:"section sorts form-group"},[i("label",[t._v("Sorts")]),i("a",{staticClass:"add",on:{click:t.addSort}},[t._v("Add +")]),i("transition-group",{attrs:{name:"form-input-section"}},t._l(t.query.sorts,function(e,s){return i("div",{key:s,staticClass:"form-group clearfix"},[i("select",{directives:[{name:"model",rawName:"v-model",value:e.name,expression:"sort.name"}],staticClass:"filter-name col-7 float-left form-control",on:{change:function(s){var i=Array.prototype.filter.call(s.target.options,function(e){return e.selected}).map(function(e){var t="_value"in e?e._value:e.value;return t});t.$set(e,"name",s.target.multiple?i:i[0])}}},[i("option",{attrs:{disabled:"",value:"null"}},[t._v("Choose")]),t._l(t.query.resource.sorts,function(e,s){return i("option",{key:s},[t._v("\n "+t._s(s)+"\n ")])})],2),i("select",{directives:[{name:"model",rawName:"v-model",value:e.dir,expression:"sort.dir"}],staticClass:"col-3 float-left form-control",on:{change:function(s){var i=Array.prototype.filter.call(s.target.options,function(e){return e.selected}).map(function(e){var t="_value"in e?e._value:e.value;return t});t.$set(e,"dir",s.target.multiple?i:i[0])}}},[i("option",{attrs:{selected:""}},[t._v("asc")]),i("option",[t._v("desc")])]),i("a",{staticClass:"remove col-1",on:{click:function(s){t.removeSort(e)}}},[t._v("x")])])}))],1),i("div",{staticClass:"section form-pagination form-group"},[i("label",[t._v("Pagination")]),t.isShowAction||!t.isRelationship?i("div",{staticClass:"form-group clearfix"},[i("input",{directives:[{name:"model",rawName:"v-model",value:t.query.page.number,expression:"query.page.number"}],staticClass:"col-5 float-left form-control",attrs:{type:"number",placeholder:"Number"},domProps:{value:t.query.page.number},on:{input:function(e){e.target.composing||t.$set(t.query.page,"number",e.target.value)}}}),i("input",{directives:[{name:"model",rawName:"v-model",value:t.query.page.size,expression:"query.page.size"}],staticClass:"col-5 float-left size form-control",attrs:{type:"number",placeholder:"Size"},domProps:{value:t.query.page.size},on:{input:function(e){e.target.composing||t.$set(t.query.page,"size",e.target.value)}}}),i("a",{staticClass:"remove col-1",on:{click:function(e){t.removePagination()}}},[t._v("x")])]):i("div",{staticClass:"form-group clearfix text-muted"},[t._v("\n Only #show supports nested pagination\n ")])])]),i("div",{staticClass:"relationships section form-group",class:(e={"editing-subrelationship":t.query.editingRelationship,nested:t.query.editingRelationship&&t.isRelationship,"active-subrelationship":t.isActiveSubrelationship,"inactive-subrelationship":!t.isActiveSubrelationship},e["depth-"+t.depth]=!0,e)},[t.query.editingRelationship&&t.isRelationship?t._e():i("label",[t._v("Relationships")]),t._l(t.query.possibleRelationships,function(e,s){return i("div",{key:s,staticClass:"relationship clearfix",class:(a={selected:t.query.relationships[s],hide:t.query.editingRelationship&&t.query.editingRelationship!=t.query.relationships[s]},a["depth-"+t.depth]=!0,a)},[i("a",{staticClass:"toggle clearfix",on:{click:function(i){t.toggleRelationship(s,e)}}},[i("div",{staticClass:"float-left name"},[t._v(t._s(s))]),t.isActiveSubrelationship?i("span",[t.query.relationships[s]?i("div",{staticClass:"badge badge-pill badge-info"},[t._v("✓")]):t._e()]):t._e()]),t.query.relationships[s]?i("a",{staticClass:"remove-field",on:{click:function(e){t.removeRelationship(s)}}},[t._v("Remove")]):t._e()]);var a})],2),t._l(t.query.relationships,function(e,s){return i("div",{key:s},[t.query.relationships[s]?i("div",{class:{hidden:t.query.editingRelationship!=t.query.relationships[s]}},[i("resource-form",{attrs:{query:t.query.relationships[s],schema:t.schema,"is-relationship":!0,isShowAction:t.isShowAction,depth:t.depth+1},on:{editRelationship:t.onSubrelationshipEdit,doneEditRelationship:t.onSubrelationshipDoneEdit}})],1):t._e()])}),i("div",{staticClass:"fields section form-group",class:{hide:t.query.editingRelationship}},[i("label",[t._v("Fields")]),t._l(t.query.resource.attributes,function(e,s){return e.readable&&"id"!=s?i("div",{key:s,staticClass:"field clearfix",class:{selected:t.query.fields[s]}},[i("a",{staticClass:"toggle clearfix",on:{click:function(i){t.toggleField(s,e)}}},[i("span",{staticClass:"name"},[t._v(t._s(s))]),t.query.fields[s]?i("span",{staticClass:"badge badge-pill badge-info"},[t._v("✓")]):t._e()])]):t._e()})],2)],2)])},x=[],S=i["a"].extend({name:"resource-form",props:["query","isShowAction","isRelationship","schema","depth"],data:function(){return{subRelationshipNames:[],isActiveSubrelationship:!1}},created:function(){},computed:{},methods:{addFilter:function(){this.query.filters.push({name:null,operator:"eq",error:null})},removeFilter:function(e){if(e.required)e.value=null;else{var t=this.query.filters.indexOf(e);this.query.filters.splice(t,1),this.query.filters.length<1&&this.addFilter()}},addSort:function(){this.query.sorts.push({name:null,dir:"asc",delete:!1})},removeSort:function(e){var t=this.query.sorts.indexOf(e);this.query.sorts.splice(t,1),0===this.query.sorts.length&&this.addSort()},removePagination:function(){this.query.page={number:null,size:null}},selectRelationship:function(e,t){var s=this,i=this.schema.getResource(t.resource);if("polymorphic_belongs_to"===t.type){var a={};t.resources.forEach(function(e){var t=s.schema.getResource(e);Object.assign(a,t.relationships)}),i={polymorphic:!0,children:t.resources,relationships:a}}var n=e;this.query.relationshipPath&&(n="".concat(this.query.relationshipPath,".").concat(e));var r=new C(this.schema,i,null,n);this.$set(this.query.relationships,e,r)},removeRelationship:function(e){this.$delete(this.query.relationships,e),this.doneEditingRelationship(e)},toggleRelationship:function(e,t){this.query.editingRelationship?this.doneEditingRelationship(e):this.query.relationships[e]?this.editRelationship(e,this.query.relationships[e]):this.selectRelationship(e,t)},editRelationship:function(e,t){this.$emit("editRelationship",e),this.query.editingRelationship=t,this.isActiveSubrelationship=!0},doneEditingRelationship:function(e){this.query.editingRelationship=!1,this.isActiveSubrelationship=!1,this.$emit("doneEditRelationship",e)},toggleField:function(e){this.query.fields[e]?this.$delete(this.query.fields,e):this.$set(this.query.fields,e,!0)},onSubrelationshipEdit:function(e){this.isActiveSubrelationship=!1},onSubrelationshipDoneEdit:function(e){this.isActiveSubrelationship=!0}}}),E=S,A=(s("fd6a"),Object(r["a"])(E,O,x,!1,null,"c7fe1220",null));A.options.__file="ResourceForm.vue";var P=A.exports,T=function(){var e,t=this,s=t.$createElement,i=t._self._c||s;return i("div",{staticClass:"data-table",class:{inactive:!t.active}},[i("div",{staticClass:"contents"},[t.label?i("div",{staticClass:"relationship-label"},[i("span",{staticClass:"arrow"},[t._v("↳")]),t._v(" "+t._s(t.label)+"\n ")]):t._e(),t.object.rows.length>0?i("div",{staticClass:"clearfix view-as-json"},[i("a",{on:{click:function(e){t.jsonView(t.object)}}},[t._v("View as JSON")])]):t._e(),t.object.rows.length>0?i("div",{staticClass:"table-wrapper"},[i("table",{staticClass:"results table table-hover table-borderless",class:(e={"has-selection":t.object.selectedRow,"is-sub-table":t.isSubTable},e[t.object.css]=!0,e)},[i("thead",[i("tr",t._l(t.object.headers,function(e){return i("th",{key:e},[t._v("\n "+t._s(e)+"\n ")])}))]),i("tbody",t._l(t.object.rows,function(e){return i("tr",{key:e.attrs.id.value,staticClass:"data-row",class:{selected:t.object.selectedRow===e,"has-relationships":e.hasRelationships},on:{click:function(s){t.toggleRow(e)}}},t._l(e.attrs,function(e,s){return i("td",{key:s,class:(a={},a["type-"+e.type]=!0,a)},[i("div",{staticClass:"td-contents"},["datetime"==e.type?i("div",[t._v("\n "+t._s(t._f("dateTimeType")(e.value))+"\n ")]):"date"==e.type?i("div",[t._v("\n "+t._s(t._f("dateType")(e.value))+"\n ")]):i("div",[t._v("\n "+t._s(e.value)+"\n ")])])]);var a}))}))])]):i("div",{staticClass:"card"},[t._v("\n No Data\n ")]),i("transition",{attrs:{name:"relationship-table"}},[0===t.depth&&t.isShowAction||t.object.selectedRow?i("span",t._l(t.relationships,function(e,s){return i("data-table",{key:s,attrs:{label:s,object:e,isSubTable:!0,depth:t.depth+1,isShowAction:t.isShowAction},on:{rowClick:t.onSubRowClick}})})):t._e()])],1)])},$=[],z=new i["a"],N=z,D=i["a"].extend({name:"data-table",props:["object","depth","label","isShowAction","isSubTable"],data:function(){return{active:!0}},computed:{relationships:function(){return this.isShowAction&&0===this.depth?this.object.rows[0].relationships:this.object.selectedRow.relationships}},methods:{jsonView:function(e){N.$emit("modalToggle",e.formattedJSON())},toggleRow:function(e){this.object.selectedRow?this.object.selectedRow=null:(this.active=!0,this.object.selectedRow=e)},onSubRowClick:function(e){this.active=!e}}}),Y=D,F=(s("9e92"),Object(r["a"])(Y,T,$,!1,null,"2f86ad40",null));F.options.__file="DataTable.vue";var M=F.exports,H=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"endpoints",class:{"has-selection":e.selection}},[s("input",{directives:[{name:"model",rawName:"v-model",value:e.query,expression:"query"}],staticClass:"form-control search",attrs:{type:"search",placeholder:"Search"},domProps:{value:e.query},on:{input:function(t){t.target.composing||(e.query=t.target.value)}}}),e._l(e.filteredEndpoints,function(t){return s("a",{key:t,staticClass:"endpoint",class:{selected:e.selection===t}},[s("div",{staticClass:"path",on:{click:function(s){e.toggle(t)}}},[e.selection===t?s("span",[e._v("« ")]):e._e(),e._v("\n "+e._s(e._f("endpointDisplay")(t))+"\n ")]),e.selection===t?s("span",[e._t("default")],2):e._e()])})],2)},I=[],U=i["a"].extend({name:"endpoint-list",props:["endpoints"],data:function(){return{selection:null,query:null}},filters:{endpointDisplay:function(e){var t=e.split("/");return t[t.length-1]}},computed:{filteredEndpoints:function(){var e=this,t=this.endpoints.filter(function(e){return e.includes("#index")||e.includes("#show")});return this.query?t.filter(function(t){return t.includes(e.query)}):t}},methods:{toggle:function(e){this.selection?this.selection=null:this.selection=e,this.$emit("toggle",this.selection)}}}),L=U,J=(s("3956"),Object(r["a"])(L,H,I,!1,null,"a79b1f96",null));J.options.__file="EndpointList.vue";var V=J.exports,W=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"url-bar"},[e.query&&e.query.endpoint?s("form",{staticClass:"query clearfix"},[s("input",{attrs:{id:"copy-url",type:"hidden"},domProps:{value:e.schema.json.base_url+e.query.url}}),s("input",{directives:[{name:"model",rawName:"v-model",value:e.query.url,expression:"query.url"}],staticClass:"form-control url",class:{firing:e.firing},attrs:{type:"text",placeholder:"URL"},domProps:{value:e.query.url},on:{input:[function(t){t.target.composing||e.$set(e.query,"url",t.target.value)},e.buildQueryObject]}}),s("div",{staticClass:"btn-group url-controls"},[s("a",{staticClass:"btn btn-secondary",attrs:{title:"Copy"},on:{click:function(t){e.copyUrl()}}},[s("i",{staticClass:"fas fa-copy"})]),s("a",{staticClass:"btn btn-secondary",attrs:{href:e.query.urlWithDomain,target:"_blank",title:"Open in new tab"}},[s("i",{staticClass:"fas fa-external-link-alt"})]),s("a",{staticClass:"btn btn-secondary",attrs:{title:"Copy as Curl"},on:{click:function(t){e.copyAsCurl()}}},[s("i",{staticClass:"fas fa-copyright"})])])]):e._e()])},G=[],B=function(e){},Q=i["a"].extend({name:"url-bar",props:["schema","query","firing"],data:function(){return{}},computed:{},methods:{copyUrl:function(){navigator["clipboard"].writeText(this.query.urlWithDomain)},copyAsCurl:function(){navigator["clipboard"].writeText(this.query.generateCurl())},buildQueryObject:function(){B(this.query)}}}),K=Q,X=(s("64c3"),Object(r["a"])(K,W,G,!1,null,"79f5869a",null));X.options.__file="UrlBar.vue";var Z=X.exports,ee=[{name:"results"},{name:"raw"},{name:"debug"}],te=i["a"].extend({name:"vandal",components:{EndpointList:V,DataTable:M,ResourceForm:P,UrlBar:Z},data:function(){return{schema:null,query:null,currentTab:ee[0],creating:!0,isLoading:!1,path:null,resource:null,modalIsOpen:!1,modalContent:null,firing:!1,resetting:!1}},created:function(){var e=this;this.fetchSchema();var t=function(){e.creating=!1};setTimeout(t,1e3),N.$on("modalToggle",this.onModalToggle)},computed:{isShowAction:function(){if(this.query)return this.query.endpoint.includes("#show")}},methods:{onModalToggle:function(e){this.modalContent=e,this.modalIsOpen=!this.modalIsOpen},toggleEndpoint:function(e){e?(this.resource=this.schema.resourceFor(e),this.reset(e,!1)):(this.resource=null,this.query=null)},fetchSchema:function(){var e=Object(f["a"])(regeneratorRuntime.mark(function e(){var t,s,i,a;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return t=new Headers,t.append("pragma","no-cache"),t.append("cache-control","no-cache"),{method:"GET",headers:t},s=document.querySelector("meta[name='schema']").getAttribute("content"),i=new Request(s),e.next=8,fetch(i);case 8:return e.next=10,e.sent.json();case 10:return a=e.sent,this.schema=new b(a),this.schema._processRemoteResources(),e.abrupt("return",this.schema);case 14:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),reset:function(e){var t=this,s=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];s&&(this.resetting=!0),this.query=new C(this.schema,this.resource,e);var i=function(){t.resetting=!1};s&&setTimeout(i,100)},fetch:function(){var e=Object(f["a"])(regeneratorRuntime.mark(function e(){var t,s,i,a=this;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:if(!this.validate()){e.next=12;break}return this.firing=!0,t=function(){a.firing=!1},setTimeout(t,100),this.isLoading=!0,s=Date.now(),e.next=8,this.query.fire();case 8:return i=Date.now(),e.next=11,this.stall(100-(i-s));case 11:this.isLoading=!1;case 12:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),validate:function(){if(this.isShowAction){var e=this.query.filters.filter(function(e){return"id"===e.name})[0];return e.value?(e.error=!1,!0):(this["tempSet"](e,"error",!0,1e3),!1)}return!0},tab:function(e){this.currentTab=ee[e]},stall:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3e3;return new Promise(function(t){return setTimeout(t,e)})}}}),se=te,ie=(s("73b3"),Object(r["a"])(se,h,d,!1,null,null,null));ie.options.__file="All.vue";var ae=ie.exports;i["a"].use(u["a"]);var ne=new u["a"]({base:"",routes:[{path:"/",name:"vandal",component:ae}]}),re=s("998c");i["a"].use(re),i["a"].config.productionTip=!1,i["a"].mixin({methods:{tempSet:function(e,t,s,i){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=e[t];null!==a&&(n=a),e[t]=s;var r=function(){e[t]=n};setTimeout(r,i)}}}),i["a"].filter("dateTimeType",function(e){if(e)return q()(String(e)).format("M/D/YYYY h:mma")}),i["a"].filter("dateType",function(e){if(e)return q()(String(e)).format("M/D/YYYY")}),new i["a"]({router:ne,render:function(e){return e(l)}}).$mount("#app")},fd6a:function(e,t,s){"use strict";var i=s("0bab"),a=s.n(i);a.a}}); 2 | //# sourceMappingURL=app.d38ac258.js.map -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /spec/api/v1/departments/create_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "departments#create", type: :request do 4 | subject(:make_request) do 5 | jsonapi_post "/api/v1/departments", payload 6 | end 7 | 8 | describe 'basic create' do 9 | let(:payload) do 10 | { 11 | data: { 12 | type: 'departments', 13 | attributes: { 14 | # ... your attrs here 15 | } 16 | } 17 | } 18 | end 19 | 20 | it 'works' do 21 | expect(DepartmentResource).to receive(:build).and_call_original 22 | expect { 23 | make_request 24 | }.to change { Department.count }.by(1) 25 | department = Department.last 26 | expect(response.status).to eq(201) 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /spec/api/v1/departments/destroy_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "departments#destroy", type: :request do 4 | subject(:make_request) do 5 | jsonapi_delete "/api/v1/departments/#{department.id}" 6 | end 7 | 8 | describe 'basic destroy' do 9 | let!(:department) { create(:department) } 10 | 11 | it 'updates the resource' do 12 | expect(DepartmentResource).to receive(:find).and_call_original 13 | expect { make_request }.to change { Department.count }.by(-1) 14 | expect { department.reload } 15 | .to raise_error(ActiveRecord::RecordNotFound) 16 | expect(response.status).to eq(200) 17 | expect(json).to eq('meta' => {}) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/api/v1/departments/index_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "departments#index", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/departments", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:department1) { create(:department) } 12 | let!(:department2) { create(:department) } 13 | 14 | it 'works' do 15 | expect(DepartmentResource).to receive(:all).and_call_original 16 | make_request 17 | expect(response.status).to eq(200) 18 | expect(d.map(&:jsonapi_type).uniq).to match_array(['departments']) 19 | expect(d.map(&:id)).to match_array([department1.id, department2.id]) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/api/v1/departments/show_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "departments#show", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/departments/#{department.id}", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:department) { create(:department) } 12 | 13 | it 'works' do 14 | expect(DepartmentResource).to receive(:find).and_call_original 15 | make_request 16 | expect(response.status).to eq(200) 17 | expect(d.jsonapi_type).to eq('departments') 18 | expect(d.id).to eq(department.id) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/api/v1/departments/update_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "departments#update", type: :request do 4 | subject(:make_request) do 5 | jsonapi_put "/api/v1/departments/#{department.id}", payload 6 | end 7 | 8 | describe 'basic update' do 9 | let!(:department) { create(:department) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | id: department.id.to_s, 15 | type: 'departments', 16 | attributes: { 17 | name: 'changed!' 18 | } 19 | } 20 | } 21 | end 22 | 23 | it 'updates the resource' do 24 | expect(DepartmentResource).to receive(:find).and_call_original 25 | expect { 26 | make_request 27 | }.to change { department.reload.attributes } 28 | expect(response.status).to eq(200) 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/api/v1/employees/create_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "employees#create", type: :request do 4 | subject(:make_request) do 5 | jsonapi_post "/api/v1/employees", payload 6 | end 7 | 8 | describe 'basic create' do 9 | let(:payload) do 10 | { 11 | data: { 12 | type: 'employees', 13 | attributes: { 14 | # ... your attrs here 15 | } 16 | } 17 | } 18 | end 19 | 20 | it 'works' do 21 | expect(EmployeeResource).to receive(:build).and_call_original 22 | expect { 23 | make_request 24 | }.to change { Employee.count }.by(1) 25 | employee = Employee.last 26 | expect(response.status).to eq(201) 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /spec/api/v1/employees/destroy_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "employees#destroy", type: :request do 4 | subject(:make_request) do 5 | jsonapi_delete "/api/v1/employees/#{employee.id}" 6 | end 7 | 8 | describe 'basic destroy' do 9 | let!(:employee) { create(:employee) } 10 | 11 | it 'updates the resource' do 12 | expect(EmployeeResource).to receive(:find).and_call_original 13 | expect { make_request }.to change { Employee.count }.by(-1) 14 | expect { employee.reload } 15 | .to raise_error(ActiveRecord::RecordNotFound) 16 | expect(response.status).to eq(200) 17 | expect(json).to eq('meta' => {}) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/api/v1/employees/index_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "employees#index", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/employees", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:employee1) { create(:employee) } 12 | let!(:employee2) { create(:employee) } 13 | 14 | it 'works' do 15 | expect(EmployeeResource).to receive(:all).and_call_original 16 | make_request 17 | expect(response.status).to eq(200) 18 | expect(d.map(&:jsonapi_type).uniq).to match_array(['employees']) 19 | expect(d.map(&:id)).to match_array([employee1.id, employee2.id]) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/api/v1/employees/show_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "employees#show", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/employees/#{employee.id}", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:employee) { create(:employee) } 12 | 13 | it 'works' do 14 | expect(EmployeeResource).to receive(:find).and_call_original 15 | make_request 16 | expect(response.status).to eq(200) 17 | expect(d.jsonapi_type).to eq('employees') 18 | expect(d.id).to eq(employee.id) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/api/v1/employees/update_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "employees#update", type: :request do 4 | subject(:make_request) do 5 | jsonapi_put "/api/v1/employees/#{employee.id}", payload 6 | end 7 | 8 | describe 'basic update' do 9 | let!(:employee) { create(:employee, age: 20) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | id: employee.id.to_s, 15 | type: 'employees', 16 | attributes: { 17 | first_name: 'updated firstname', 18 | } 19 | } 20 | } 21 | end 22 | 23 | it 'updates the resource' do 24 | expect(EmployeeResource).to receive(:find).and_call_original 25 | expect { 26 | make_request 27 | }.to change { employee.reload.attributes } 28 | expect(response.status).to eq(200) 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/api/v1/milestones/create_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "milestones#create", type: :request do 4 | subject(:make_request) do 5 | jsonapi_post "/api/v1/milestones", payload 6 | end 7 | 8 | describe 'basic create' do 9 | let!(:epic) { create(:epic) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | type: 'milestones', 15 | attributes: { 16 | }, 17 | relationships: { 18 | epic: { 19 | data: { 20 | id: epic.id.to_s, 21 | type: 'epics' 22 | } 23 | } 24 | } 25 | } 26 | } 27 | end 28 | 29 | it 'works' do 30 | expect(MilestoneResource).to receive(:build).and_call_original 31 | expect { 32 | make_request 33 | }.to change { Milestone.count }.by(1) 34 | milestone = Milestone.last 35 | expect(response.status).to eq(201) 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /spec/api/v1/milestones/destroy_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "milestones#destroy", type: :request do 4 | subject(:make_request) do 5 | jsonapi_delete "/api/v1/milestones/#{milestone.id}" 6 | end 7 | 8 | describe 'basic destroy' do 9 | let!(:milestone) { create(:milestone) } 10 | 11 | it 'updates the resource' do 12 | expect(MilestoneResource).to receive(:find).and_call_original 13 | expect { make_request }.to change { Milestone.count }.by(-1) 14 | expect { milestone.reload } 15 | .to raise_error(ActiveRecord::RecordNotFound) 16 | expect(response.status).to eq(200) 17 | expect(json).to eq('meta' => {}) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/api/v1/milestones/index_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "milestones#index", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/milestones", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:milestone1) { create(:milestone) } 12 | let!(:milestone2) { create(:milestone) } 13 | 14 | it 'works' do 15 | expect(MilestoneResource).to receive(:all).and_call_original 16 | make_request 17 | expect(response.status).to eq(200) 18 | expect(d.map(&:jsonapi_type).uniq).to match_array(['milestones']) 19 | expect(d.map(&:id)).to match_array([milestone1.id, milestone2.id]) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/api/v1/milestones/show_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "milestones#show", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/milestones/#{milestone.id}", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:milestone) { create(:milestone) } 12 | 13 | it 'works' do 14 | expect(MilestoneResource).to receive(:find).and_call_original 15 | make_request 16 | expect(response.status).to eq(200) 17 | expect(d.jsonapi_type).to eq('milestones') 18 | expect(d.id).to eq(milestone.id) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/api/v1/milestones/update_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "milestones#update", type: :request do 4 | subject(:make_request) do 5 | jsonapi_put "/api/v1/milestones/#{milestone.id}", payload 6 | end 7 | 8 | describe 'basic update' do 9 | let!(:milestone) { create(:milestone) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | id: milestone.id.to_s, 15 | type: 'milestones', 16 | attributes: { 17 | name: 'changed!' 18 | } 19 | } 20 | } 21 | end 22 | 23 | it 'updates the resource' do 24 | expect(MilestoneResource).to receive(:find).and_call_original 25 | expect { 26 | make_request 27 | }.to change { milestone.reload.attributes } 28 | expect(response.status).to eq(200) 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/api/v1/notes/create_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "notes#create", type: :request do 4 | subject(:make_request) do 5 | jsonapi_post "/api/v1/notes", payload 6 | end 7 | 8 | describe 'basic create' do 9 | let!(:department) { create(:department) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | type: 'notes', 15 | attributes: { 16 | }, 17 | relationships: { 18 | notable: { 19 | data: { 20 | type: 'departments', 21 | id: department.id.to_s 22 | } 23 | } 24 | } 25 | } 26 | } 27 | end 28 | 29 | it 'works' do 30 | expect(NoteResource).to receive(:build).and_call_original 31 | expect { 32 | make_request 33 | }.to change { Note.count }.by(1) 34 | note = Note.last 35 | expect(response.status).to eq(201) 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /spec/api/v1/notes/destroy_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "notes#destroy", type: :request do 4 | subject(:make_request) do 5 | jsonapi_delete "/api/v1/notes/#{note.id}" 6 | end 7 | 8 | describe 'basic destroy' do 9 | let!(:note) { create(:employee_note) } 10 | 11 | it 'updates the resource' do 12 | expect(NoteResource).to receive(:find).and_call_original 13 | expect { make_request }.to change { Note.count }.by(-1) 14 | expect { note.reload } 15 | .to raise_error(ActiveRecord::RecordNotFound) 16 | expect(response.status).to eq(200) 17 | expect(json).to eq('meta' => {}) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/api/v1/notes/index_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "notes#index", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/notes", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:note1) { create(:team_note) } 12 | let!(:note2) { create(:department_note) } 13 | 14 | it 'works' do 15 | expect(NoteResource).to receive(:all).and_call_original 16 | make_request 17 | expect(response.status).to eq(200) 18 | expect(d.map(&:jsonapi_type).uniq).to match_array(['notes']) 19 | expect(d.map(&:id)).to match_array([note1.id, note2.id]) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/api/v1/notes/show_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "notes#show", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/notes/#{note.id}", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:note) { create(:employee_note) } 12 | 13 | it 'works' do 14 | expect(NoteResource).to receive(:find).and_call_original 15 | make_request 16 | expect(response.status).to eq(200) 17 | expect(d.jsonapi_type).to eq('notes') 18 | expect(d.id).to eq(note.id) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/api/v1/notes/update_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "notes#update", type: :request do 4 | subject(:make_request) do 5 | jsonapi_put "/api/v1/notes/#{note.id}", payload 6 | end 7 | 8 | describe 'basic update' do 9 | let!(:note) { create(:department_note) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | id: note.id.to_s, 15 | type: 'notes', 16 | attributes: { 17 | body: 'changed!' 18 | } 19 | } 20 | } 21 | end 22 | 23 | it 'updates the resource' do 24 | expect(NoteResource).to receive(:find).and_call_original 25 | expect { 26 | make_request 27 | }.to change { note.reload.attributes } 28 | expect(response.status).to eq(200) 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/api/v1/positions/create_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "positions#create", type: :request do 4 | subject(:make_request) do 5 | jsonapi_post "/api/v1/positions", payload 6 | end 7 | 8 | describe 'basic create' do 9 | let!(:employee) { create(:employee) } 10 | let!(:department) { create(:department) } 11 | 12 | let(:payload) do 13 | { 14 | data: { 15 | type: 'positions', 16 | attributes: { }, 17 | relationships: { 18 | employee: { 19 | data: { 20 | id: employee.id.to_s, 21 | type: 'employees' 22 | } 23 | }, 24 | department: { 25 | data: { 26 | id: department.id.to_s, 27 | type: 'departments' 28 | } 29 | } 30 | } 31 | } 32 | } 33 | end 34 | 35 | it 'works' do 36 | expect(PositionResource).to receive(:build).and_call_original 37 | expect { 38 | make_request 39 | }.to change { Position.count }.by(1) 40 | expect(response.status).to eq(201) 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /spec/api/v1/positions/destroy_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "positions#destroy", type: :request do 4 | subject(:make_request) do 5 | jsonapi_delete "/api/v1/positions/#{position.id}" 6 | end 7 | 8 | describe 'basic destroy' do 9 | let!(:position) { create(:position) } 10 | 11 | it 'updates the resource' do 12 | expect(PositionResource).to receive(:find).and_call_original 13 | expect { make_request }.to change { Position.count }.by(-1) 14 | expect { position.reload } 15 | .to raise_error(ActiveRecord::RecordNotFound) 16 | expect(response.status).to eq(200) 17 | expect(json).to eq('meta' => {}) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/api/v1/positions/index_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "positions#index", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/positions", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:position1) { create(:position) } 12 | let!(:position2) { create(:position) } 13 | 14 | it 'works' do 15 | expect(PositionResource).to receive(:all).and_call_original 16 | make_request 17 | expect(response.status).to eq(200) 18 | expect(d.map(&:jsonapi_type).uniq).to match_array(['positions']) 19 | expect(d.map(&:id)).to match_array([position1.id, position2.id]) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/api/v1/positions/show_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "positions#show", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/positions/#{position.id}", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:position) { create(:position) } 12 | 13 | it 'works' do 14 | expect(PositionResource).to receive(:find).and_call_original 15 | make_request 16 | expect(response.status).to eq(200) 17 | expect(d.jsonapi_type).to eq('positions') 18 | expect(d.id).to eq(position.id) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/api/v1/positions/update_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "positions#update", type: :request do 4 | subject(:make_request) do 5 | jsonapi_put "/api/v1/positions/#{position.id}", payload 6 | end 7 | 8 | describe 'basic update' do 9 | let!(:position) { create(:position) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | id: position.id.to_s, 15 | type: 'positions', 16 | attributes: { 17 | title: 'changed!' 18 | } 19 | } 20 | } 21 | end 22 | 23 | it 'updates the resource' do 24 | expect(PositionResource).to receive(:find).and_call_original 25 | expect { 26 | make_request 27 | }.to change { position.reload.attributes } 28 | expect(response.status).to eq(200) 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/api/v1/tasks/create_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "tasks#create", type: :request do 4 | subject(:make_request) do 5 | jsonapi_post "/api/v1/tasks", payload 6 | end 7 | 8 | describe 'basic create' do 9 | let(:payload) do 10 | { 11 | data: { 12 | type: 'bugs', 13 | attributes: { 14 | } 15 | } 16 | } 17 | end 18 | 19 | it 'works' do 20 | expect(TaskResource).to receive(:build).and_call_original 21 | expect { 22 | make_request 23 | }.to change { Bug.count }.by(1) 24 | expect(response.status).to eq(201) 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /spec/api/v1/tasks/destroy_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "tasks#destroy", type: :request do 4 | subject(:make_request) do 5 | jsonapi_delete "/api/v1/tasks/#{task.id}" 6 | end 7 | 8 | describe 'basic destroy' do 9 | let!(:task) { create(:task) } 10 | 11 | it 'updates the resource' do 12 | expect(TaskResource).to receive(:find).and_call_original 13 | expect { make_request }.to change { Task.count }.by(-1) 14 | expect { task.reload } 15 | .to raise_error(ActiveRecord::RecordNotFound) 16 | expect(response.status).to eq(200) 17 | expect(json).to eq('meta' => {}) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/api/v1/tasks/index_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "tasks#index", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/tasks", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:task1) { create(:bug) } 12 | let!(:task2) { create(:feature) } 13 | let!(:task3) { create(:epic) } 14 | 15 | it 'works' do 16 | expect(TaskResource).to receive(:all).and_call_original 17 | make_request 18 | expect(response.status).to eq(200) 19 | expect(d.map(&:jsonapi_type).uniq) 20 | .to match_array(%w(bugs features epics)) 21 | expect(d.map(&:id)).to match_array([task1.id, task2.id, task3.id]) 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /spec/api/v1/tasks/show_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "tasks#show", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/tasks/#{task.id}", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:task) { create(:feature) } 12 | 13 | it 'works' do 14 | expect(TaskResource).to receive(:find).and_call_original 15 | make_request 16 | expect(response.status).to eq(200) 17 | expect(d.jsonapi_type).to eq('features') 18 | expect(d.id).to eq(task.id) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/api/v1/tasks/update_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "tasks#update", type: :request do 4 | subject(:make_request) do 5 | jsonapi_put "/api/v1/tasks/#{task.id}", payload 6 | end 7 | 8 | describe 'basic update' do 9 | let!(:task) { create(:task) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | id: task.id.to_s, 15 | type: 'tasks', 16 | attributes: { 17 | title: 'changed!' 18 | } 19 | } 20 | } 21 | end 22 | 23 | it 'updates the resource' do 24 | expect(TaskResource).to receive(:find).and_call_original 25 | expect { 26 | make_request 27 | }.to change { task.reload.attributes } 28 | expect(response.status).to eq(200) 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/api/v1/teams/create_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "teams#create", type: :request do 4 | subject(:make_request) do 5 | jsonapi_post "/api/v1/teams", payload 6 | end 7 | 8 | describe 'basic create' do 9 | let!(:department) { create(:department) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | type: 'teams', 15 | attributes: { 16 | }, 17 | relationships: { 18 | department: { 19 | data: { 20 | id: department.id.to_s, 21 | type: 'departments' 22 | } 23 | } 24 | } 25 | } 26 | } 27 | end 28 | 29 | it 'works' do 30 | expect(TeamResource).to receive(:build).and_call_original 31 | expect { 32 | make_request 33 | }.to change { Team.count }.by(1) 34 | team = Team.last 35 | expect(response.status).to eq(201) 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /spec/api/v1/teams/destroy_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "teams#destroy", type: :request do 4 | subject(:make_request) do 5 | jsonapi_delete "/api/v1/teams/#{team.id}" 6 | end 7 | 8 | describe 'basic destroy' do 9 | let!(:team) { create(:team) } 10 | 11 | it 'updates the resource' do 12 | expect(TeamResource).to receive(:find).and_call_original 13 | expect { make_request }.to change { Team.count }.by(-1) 14 | expect { team.reload } 15 | .to raise_error(ActiveRecord::RecordNotFound) 16 | expect(response.status).to eq(200) 17 | expect(json).to eq('meta' => {}) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/api/v1/teams/index_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "teams#index", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/teams", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:team1) { create(:team) } 12 | let!(:team2) { create(:team) } 13 | 14 | it 'works' do 15 | expect(TeamResource).to receive(:all).and_call_original 16 | make_request 17 | expect(response.status).to eq(200) 18 | expect(d.map(&:jsonapi_type).uniq).to match_array(['teams']) 19 | expect(d.map(&:id)).to match_array([team1.id, team2.id]) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/api/v1/teams/show_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "teams#show", type: :request do 4 | let(:params) { {} } 5 | 6 | subject(:make_request) do 7 | jsonapi_get "/api/v1/teams/#{team.id}", params: params 8 | end 9 | 10 | describe 'basic fetch' do 11 | let!(:team) { create(:team) } 12 | 13 | it 'works' do 14 | expect(TeamResource).to receive(:find).and_call_original 15 | make_request 16 | expect(response.status).to eq(200) 17 | expect(d.jsonapi_type).to eq('teams') 18 | expect(d.id).to eq(team.id) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/api/v1/teams/update_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe "teams#update", type: :request do 4 | subject(:make_request) do 5 | jsonapi_put "/api/v1/teams/#{team.id}", payload 6 | end 7 | 8 | describe 'basic update' do 9 | let!(:team) { create(:team) } 10 | 11 | let(:payload) do 12 | { 13 | data: { 14 | id: team.id.to_s, 15 | type: 'teams', 16 | attributes: { 17 | name: 'changed!' 18 | } 19 | } 20 | } 21 | end 22 | 23 | it 'updates the resource' do 24 | expect(TeamResource).to receive(:find).and_call_original 25 | expect { 26 | make_request 27 | }.to change { team.reload.attributes } 28 | expect(response.status).to eq(200) 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/factories/departments.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :department do 3 | name { Faker::Lorem.word.titleize } 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /spec/factories/employees.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :employee do 3 | first_name { Faker::Name.first_name } 4 | last_name { Faker::Name.last_name } 5 | age { rand(20..80) } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/factories/milestones.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :milestone do 3 | epic 4 | 5 | name { Faker::Lorem.word } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/factories/notes.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :note do 3 | body { Faker::Lorem.sentence } 4 | end 5 | 6 | factory :employee_note, parent: :note do 7 | association :notable, factory: :employee 8 | end 9 | 10 | factory :department_note, parent: :note do 11 | association :notable, factory: :department 12 | end 13 | 14 | factory :team_note, parent: :note do 15 | association :notable, factory: :team 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/factories/positions.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :position do 3 | employee 4 | department 5 | 6 | title { Faker::Job.title } 7 | 8 | after(:create) do |position| 9 | unless position.historical_index 10 | Position.reorder!(position.employee.id) 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/factories/tasks.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :task do 3 | title { Faker::Lorem.word.titleize } 4 | type { Task::TYPES.sample } 5 | end 6 | 7 | factory :bug, parent: :task, class: 'Bug' do 8 | type { 'Bug' } 9 | end 10 | 11 | factory :feature, parent: :task, class: 'Feature' do 12 | type { 'Feature' } 13 | end 14 | 15 | factory :epic, parent: :task, class: 'Epic' do 16 | type { 'Epic' } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/factories/team_memberships.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :team_membership do 3 | employee 4 | team 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /spec/factories/teams.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :team do 3 | department 4 | 5 | name { Faker::Lorem.word } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/models/position_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Position do 4 | describe 'scopes' do 5 | describe '.current' do 6 | subject { described_class.current(value) } 7 | 8 | let!(:pos1) { create(:position, historical_index: 1) } 9 | let!(:pos2) { create(:position, historical_index: 2) } 10 | 11 | context 'when true' do 12 | let(:value) { true } 13 | 14 | it 'finds all positions that are historical index 1' do 15 | expect(subject).to eq([pos1]) 16 | end 17 | end 18 | 19 | context 'when false' do 20 | let(:value) { false } 21 | 22 | it 'finds all positions that are not historical index 1' do 23 | expect(subject).to eq([pos2]) 24 | end 25 | end 26 | end 27 | 28 | describe '.reorder!' do 29 | let!(:employee) { create(:employee) } 30 | let!(:pos1) do 31 | create(:position, employee: employee, historical_index: 2) 32 | end 33 | let!(:pos2) do 34 | create(:position, employee: employee, historical_index: 3) 35 | end 36 | let!(:pos3) do 37 | create(:position, employee: employee, historical_index: 1) 38 | end 39 | let!(:pos4) do 40 | create(:position, employee: employee, historical_index: 4) 41 | end 42 | 43 | it 'updates historical index based on recency' do 44 | Position.reorder!(employee.id) 45 | indices = [pos1, pos2, pos3, pos4] 46 | indices.each(&:reload) 47 | expect(indices.map(&:historical_index)).to eq([4, 3, 2, 1]) 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | ENV['RAILS_ENV'] ||= 'test' 3 | require File.expand_path('../../config/environment', __FILE__) 4 | # Prevent database truncation if the environment is production 5 | abort("The Rails environment is running in production mode!") if Rails.env.production? 6 | require 'spec_helper' 7 | require 'rspec/rails' 8 | require 'graphiti_spec_helpers/rspec' 9 | # Add additional requires below this line. Rails is not loaded until this point! 10 | 11 | # Requires supporting ruby files with custom matchers and macros, etc, in 12 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 13 | # run as spec files by default. This means that files in spec/support that end 14 | # in _spec.rb will both be required and run as specs, causing the specs to be 15 | # run twice. It is recommended that you do not name files matching this glob to 16 | # end with _spec.rb. You can configure this pattern with the --pattern 17 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 18 | # 19 | # The following line is provided for convenience purposes. It has the downside 20 | # of increasing the boot-up time by auto-requiring all files in the support 21 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 22 | # require only the support files necessary. 23 | # 24 | # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } 25 | 26 | # Checks for pending migration and applies them before tests are run. 27 | # If you are not using ActiveRecord, you can remove this line. 28 | ActiveRecord::Migration.maintain_test_schema! 29 | 30 | RSpec.configure do |config| 31 | config.include FactoryBot::Syntax::Methods 32 | config.include GraphitiSpecHelpers::RSpec 33 | config.include GraphitiSpecHelpers::Sugar 34 | config.include Graphiti::Rails::TestHelpers 35 | 36 | config.before :each do 37 | handle_request_exceptions(false) 38 | end 39 | 40 | # bootstrap database cleaner 41 | config.before(:suite) do 42 | DatabaseCleaner.strategy = :transaction 43 | DatabaseCleaner.clean_with(:truncation) 44 | end 45 | 46 | config.around(:each) do |example| 47 | begin 48 | DatabaseCleaner.cleaning do 49 | example.run 50 | end 51 | ensure 52 | DatabaseCleaner.clean 53 | end 54 | end 55 | 56 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 57 | # config.fixture_path = "#{::Rails.root}/spec/fixtures" 58 | 59 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 60 | # examples within a transaction, remove the following line or assign false 61 | # instead of true. 62 | # config.use_transactional_fixtures = true 63 | 64 | # RSpec Rails can automatically mix in different behaviours to your tests 65 | # based on their file location, for example enabling you to call `get` and 66 | # `post` in specs under `spec/controllers`. 67 | # 68 | # You can disable this behaviour by removing the line below, and instead 69 | # explicitly tag your specs with their type, e.g.: 70 | # 71 | # RSpec.describe UsersController, :type => :controller do 72 | # # ... 73 | # end 74 | # 75 | # The different available types are documented in the features, such as in 76 | # https://relishapp.com/rspec/rspec-rails/docs 77 | config.infer_spec_type_from_file_location! 78 | 79 | # Filter lines from Rails gems in backtraces. 80 | config.filter_rails_from_backtrace! 81 | # arbitrary gems may also be filtered via: 82 | # config.filter_gems_from_backtrace("gem name") 83 | end 84 | 85 | GraphitiSpecHelpers::RSpec.schema! 86 | -------------------------------------------------------------------------------- /spec/resources/department/reads_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe DepartmentResource, type: :resource do 4 | describe 'serialization' do 5 | let!(:department) { create(:department, name: 'my department') } 6 | 7 | it 'works' do 8 | render 9 | data = jsonapi_data[0] 10 | expect(data.id).to eq(department.id) 11 | expect(data.jsonapi_type).to eq('departments') 12 | expect(data.name).to eq('my department') 13 | end 14 | end 15 | 16 | describe 'filtering' do 17 | let!(:department1) { create(:department) } 18 | let!(:department2) { create(:department) } 19 | 20 | context 'by id' do 21 | before do 22 | params[:filter] = { id: { eq: department2.id } } 23 | end 24 | 25 | it 'works' do 26 | render 27 | expect(d.map(&:id)).to eq([department2.id]) 28 | end 29 | end 30 | end 31 | 32 | describe 'sorting' do 33 | describe 'by id' do 34 | let!(:department1) { create(:department) } 35 | let!(:department2) { create(:department) } 36 | 37 | context 'when ascending' do 38 | before do 39 | params[:sort] = 'id' 40 | end 41 | 42 | it 'works' do 43 | render 44 | expect(d.map(&:id)).to eq([ 45 | department1.id, 46 | department2.id 47 | ]) 48 | end 49 | end 50 | 51 | context 'when descending' do 52 | before do 53 | params[:sort] = '-id' 54 | end 55 | 56 | it 'works' do 57 | render 58 | expect(d.map(&:id)).to eq([ 59 | department2.id, 60 | department1.id 61 | ]) 62 | end 63 | end 64 | end 65 | end 66 | 67 | describe 'sideloading' do 68 | # ... your tests ... 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /spec/resources/department/writes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe DepartmentResource, type: :resource do 4 | describe 'creating' do 5 | let(:payload) do 6 | { 7 | data: { 8 | type: 'departments', 9 | attributes: { } 10 | } 11 | } 12 | end 13 | 14 | let(:instance) do 15 | DepartmentResource.build(payload) 16 | end 17 | 18 | it 'works' do 19 | expect { 20 | expect(instance.save).to eq(true) 21 | }.to change { Department.count }.by(1) 22 | end 23 | end 24 | 25 | describe 'updating' do 26 | let!(:department) { create(:department) } 27 | 28 | let(:payload) do 29 | { 30 | data: { 31 | id: department.id.to_s, 32 | type: 'departments', 33 | attributes: { name: 'changed!' } 34 | } 35 | } 36 | end 37 | 38 | let(:instance) do 39 | DepartmentResource.find(payload) 40 | end 41 | 42 | it 'works' do 43 | expect { 44 | expect(instance.update_attributes).to eq(true) 45 | }.to change { department.reload.updated_at } 46 | .and change { department.name }.to('changed!') 47 | end 48 | end 49 | 50 | describe 'destroying' do 51 | let!(:department) { create(:department) } 52 | 53 | let(:instance) do 54 | DepartmentResource.find(id: department.id) 55 | end 56 | 57 | it 'works' do 58 | expect { 59 | expect(instance.destroy).to eq(true) 60 | }.to change { Department.count }.by(-1) 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /spec/resources/employee/reads_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe EmployeeResource, type: :resource do 4 | describe 'serialization' do 5 | let!(:employee) { create(:employee, attrs) } 6 | 7 | let(:attrs) do 8 | { 9 | first_name: 'jane', 10 | last_name: 'doe', 11 | age: 40 12 | } 13 | end 14 | 15 | it 'works' do 16 | render 17 | data = jsonapi_data[0] 18 | expect(data.id).to eq(employee.id) 19 | expect(data.jsonapi_type).to eq('employees') 20 | expect(data.first_name).to eq('jane') 21 | expect(data.last_name).to eq('doe') 22 | expect(data.age).to eq(40) 23 | expect(data.created_at).to eq(datetime(employee.created_at)) 24 | expect(data.updated_at).to eq(datetime(employee.updated_at)) 25 | end 26 | end 27 | 28 | describe 'filtering' do 29 | let!(:employee1) { create(:employee) } 30 | let!(:employee2) { create(:employee) } 31 | 32 | context 'by id' do 33 | before do 34 | params[:filter] = { id: { eq: employee2.id } } 35 | end 36 | 37 | it 'works' do 38 | render 39 | expect(d.map(&:id)).to eq([employee2.id]) 40 | end 41 | end 42 | 43 | describe 'by title' do 44 | let!(:employee3) { create(:employee) } 45 | 46 | # correct title, but not current 47 | let!(:pos1) do 48 | create :position, 49 | employee: employee1, 50 | title: 'manager', 51 | historical_index: 2 52 | end 53 | # wrong title 54 | let!(:pos2) do 55 | create :position, 56 | employee: employee3, 57 | title: 'engineer', 58 | historical_index: 1 59 | end 60 | # good! 61 | let!(:pos3) do 62 | create :position, 63 | employee: employee2, 64 | title: 'manager', 65 | historical_index: 1 66 | end 67 | 68 | before do 69 | params[:filter] = { title: 'manager' } 70 | end 71 | 72 | it 'returns employees who have a current position with the given title' do 73 | render 74 | expect(d.map(&:id)).to eq([employee2.id]) 75 | end 76 | end 77 | end 78 | 79 | describe 'sorting' do 80 | describe 'by id' do 81 | let!(:employee1) { create(:employee) } 82 | let!(:employee2) { create(:employee) } 83 | 84 | context 'when ascending' do 85 | before do 86 | params[:sort] = 'id' 87 | end 88 | 89 | it 'works' do 90 | render 91 | expect(d.map(&:id)).to eq([ 92 | employee1.id, 93 | employee2.id 94 | ]) 95 | end 96 | end 97 | 98 | context 'when descending' do 99 | before do 100 | params[:sort] = '-id' 101 | end 102 | 103 | it 'works' do 104 | render 105 | expect(d.map(&:id)).to eq([ 106 | employee2.id, 107 | employee1.id 108 | ]) 109 | end 110 | end 111 | end 112 | 113 | describe 'by title' do 114 | let!(:employee1) { create(:employee) } 115 | let!(:employee2) { create(:employee) } 116 | let!(:pos1) { create(:position, employee: employee1, title: 'x') } 117 | let!(:pos2) do 118 | create(:position, employee: employee2, title: 'z', historical_index: 2) 119 | end 120 | let!(:pos3) { create(:position, employee: employee2, title: 'a') } 121 | 122 | context 'when asc' do 123 | before do 124 | params[:sort] = 'title' 125 | end 126 | 127 | it 'works' do 128 | render 129 | expect(d.map(&:id)).to eq([employee2.id, employee1.id]) 130 | end 131 | end 132 | 133 | context 'when desc' do 134 | before do 135 | params[:sort] = '-title' 136 | end 137 | 138 | it 'works' do 139 | render 140 | expect(d.map(&:id)).to eq([employee1.id, employee2.id]) 141 | end 142 | end 143 | end 144 | 145 | describe 'by department name' do 146 | let!(:employee1) { create(:employee) } 147 | let!(:employee2) { create(:employee) } 148 | let!(:pos1) do 149 | create(:position, employee: employee1, department: department1) 150 | end 151 | let!(:pos2) do 152 | create :position, 153 | employee: employee2, 154 | department: department2, 155 | historical_index: 2 156 | end 157 | let!(:pos3) do 158 | create :position, 159 | employee: employee2, 160 | department: department3 161 | end 162 | 163 | let!(:department1) { create(:department, name: 'z') } 164 | let!(:department2) { create(:department, name: 'a') } 165 | let!(:department3) { create(:department, name: 'b') } 166 | 167 | context 'when asc' do 168 | before do 169 | params[:sort] = 'department_name' 170 | end 171 | 172 | it 'works' do 173 | render 174 | expect(d.map(&:id)).to eq([employee2.id, employee1.id]) 175 | end 176 | end 177 | 178 | context 'when desc' do 179 | before do 180 | params[:sort] = '-department_name' 181 | end 182 | 183 | it 'works' do 184 | render 185 | expect(d.map(&:id)).to eq([employee1.id, employee2.id]) 186 | end 187 | end 188 | end 189 | end 190 | 191 | describe 'sideloading' do 192 | let!(:employee) { create(:employee) } 193 | 194 | describe 'current_position' do 195 | let!(:pos1) do 196 | create(:position, employee: employee, historical_index: 2) 197 | end 198 | let!(:pos2) do 199 | create(:position, employee: employee, historical_index: 1) 200 | end 201 | 202 | before do 203 | params[:include] = 'current_position' 204 | end 205 | 206 | it 'returns position with historical index == 1' do 207 | render 208 | sl = d[0].sideload(:current_position) 209 | expect(sl.jsonapi_type).to eq('positions') 210 | expect(sl.id).to eq(pos2.id) 211 | end 212 | end 213 | end 214 | end 215 | -------------------------------------------------------------------------------- /spec/resources/employee/writes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe EmployeeResource, type: :resource do 4 | describe 'creating' do 5 | let(:payload) do 6 | { 7 | data: { 8 | type: 'employees', 9 | attributes: { } 10 | } 11 | } 12 | end 13 | 14 | let(:instance) do 15 | EmployeeResource.build(payload) 16 | end 17 | 18 | it 'works' do 19 | expect { 20 | expect(instance.save).to eq(true) 21 | }.to change { Employee.count }.by(1) 22 | end 23 | end 24 | 25 | describe 'updating' do 26 | let!(:employee) { create(:employee, age: 20) } 27 | 28 | let(:payload) do 29 | { 30 | data: { 31 | id: employee.id.to_s, 32 | type: 'employees', 33 | attributes: { 34 | first_name: 'updated firstname', 35 | last_name: 'updated lastname', 36 | age: 70 37 | } 38 | } 39 | } 40 | end 41 | 42 | let(:instance) do 43 | EmployeeResource.find(payload) 44 | end 45 | 46 | it 'works' do 47 | expect { 48 | expect(instance.update_attributes).to eq(true) 49 | }.to change { employee.reload.updated_at } 50 | .and change { employee.first_name }.to('updated firstname') 51 | .and change { employee.last_name }.to('updated lastname') 52 | .and change { employee.age }.to(70) 53 | end 54 | end 55 | 56 | describe 'destroying' do 57 | let!(:employee) { create(:employee) } 58 | 59 | let(:instance) do 60 | EmployeeResource.find(id: employee.id) 61 | end 62 | 63 | it 'works' do 64 | expect { 65 | expect(instance.destroy).to eq(true) 66 | }.to change { Employee.count }.by(-1) 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /spec/resources/milestone/reads_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe MilestoneResource, type: :resource do 4 | describe 'serialization' do 5 | let!(:milestone) { create(:milestone, name: 'myname') } 6 | 7 | it 'works' do 8 | render 9 | data = jsonapi_data[0] 10 | expect(data.id).to eq(milestone.id) 11 | expect(data.jsonapi_type).to eq('milestones') 12 | expect(data.name).to eq('myname') 13 | end 14 | end 15 | 16 | describe 'filtering' do 17 | let!(:milestone1) { create(:milestone) } 18 | let!(:milestone2) { create(:milestone) } 19 | 20 | context 'by id' do 21 | before do 22 | params[:filter] = { id: { eq: milestone2.id } } 23 | end 24 | 25 | it 'works' do 26 | render 27 | expect(d.map(&:id)).to eq([milestone2.id]) 28 | end 29 | end 30 | end 31 | 32 | describe 'sorting' do 33 | describe 'by id' do 34 | let!(:milestone1) { create(:milestone) } 35 | let!(:milestone2) { create(:milestone) } 36 | 37 | context 'when ascending' do 38 | before do 39 | params[:sort] = 'id' 40 | end 41 | 42 | it 'works' do 43 | render 44 | expect(d.map(&:id)).to eq([ 45 | milestone1.id, 46 | milestone2.id 47 | ]) 48 | end 49 | end 50 | 51 | context 'when descending' do 52 | before do 53 | params[:sort] = '-id' 54 | end 55 | 56 | it 'works' do 57 | render 58 | expect(d.map(&:id)).to eq([ 59 | milestone2.id, 60 | milestone1.id 61 | ]) 62 | end 63 | end 64 | end 65 | end 66 | 67 | describe 'sideloading' do 68 | # ... your tests ... 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /spec/resources/milestone/writes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe MilestoneResource, type: :resource do 4 | describe 'creating' do 5 | let!(:epic) { create(:epic) } 6 | 7 | let(:payload) do 8 | { 9 | data: { 10 | type: 'milestones', 11 | attributes: { }, 12 | relationships: { 13 | epic: { 14 | data: { 15 | type: 'epics', 16 | id: epic.id.to_s 17 | } 18 | } 19 | } 20 | } 21 | } 22 | end 23 | 24 | let(:instance) do 25 | MilestoneResource.build(payload) 26 | end 27 | 28 | it 'works' do 29 | expect { 30 | expect(instance.save).to eq(true) 31 | }.to change { Milestone.count }.by(1) 32 | end 33 | end 34 | 35 | describe 'updating' do 36 | let!(:milestone) { create(:milestone) } 37 | 38 | let(:payload) do 39 | { 40 | data: { 41 | id: milestone.id.to_s, 42 | type: 'milestones', 43 | attributes: { name: 'changed!' } 44 | } 45 | } 46 | end 47 | 48 | let(:instance) do 49 | MilestoneResource.find(payload) 50 | end 51 | 52 | it 'works' do 53 | expect { 54 | expect(instance.update_attributes).to eq(true) 55 | }.to change { milestone.reload.updated_at } 56 | .and change { milestone.name }.to('changed!') 57 | end 58 | end 59 | 60 | describe 'destroying' do 61 | let!(:milestone) { create(:milestone) } 62 | 63 | let(:instance) do 64 | MilestoneResource.find(id: milestone.id) 65 | end 66 | 67 | it 'works' do 68 | expect { 69 | expect(instance.destroy).to eq(true) 70 | }.to change { Milestone.count }.by(-1) 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /spec/resources/note/reads_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe NoteResource, type: :resource do 4 | describe 'serialization' do 5 | let!(:note) { create(:employee_note, body: 'body!') } 6 | 7 | it 'works' do 8 | render 9 | data = jsonapi_data[0] 10 | expect(data.id).to eq(note.id) 11 | expect(data.jsonapi_type).to eq('notes') 12 | expect(data.body).to eq('body!') 13 | end 14 | end 15 | 16 | describe 'filtering' do 17 | let!(:note1) { create(:department_note) } 18 | let!(:note2) { create(:employee_note) } 19 | 20 | context 'by id' do 21 | before do 22 | params[:filter] = { id: { eq: note2.id } } 23 | end 24 | 25 | it 'works' do 26 | render 27 | expect(d.map(&:id)).to eq([note2.id]) 28 | end 29 | end 30 | end 31 | 32 | describe 'sorting' do 33 | describe 'by id' do 34 | let!(:note1) { create(:department_note) } 35 | let!(:note2) { create(:employee_note) } 36 | 37 | context 'when ascending' do 38 | before do 39 | params[:sort] = 'id' 40 | end 41 | 42 | it 'works' do 43 | render 44 | expect(d.map(&:id)).to eq([ 45 | note1.id, 46 | note2.id 47 | ]) 48 | end 49 | end 50 | 51 | context 'when descending' do 52 | before do 53 | params[:sort] = '-id' 54 | end 55 | 56 | it 'works' do 57 | render 58 | expect(d.map(&:id)).to eq([ 59 | note2.id, 60 | note1.id 61 | ]) 62 | end 63 | end 64 | end 65 | end 66 | 67 | describe 'sideloading' do 68 | # ... your tests ... 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /spec/resources/note/writes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe NoteResource, type: :resource do 4 | describe 'creating' do 5 | let!(:employee) { create(:employee) } 6 | 7 | let(:payload) do 8 | { 9 | data: { 10 | type: 'notes', 11 | attributes: { }, 12 | relationships: { 13 | notable: { 14 | data: { 15 | type: 'employees', 16 | id: employee.id 17 | } 18 | } 19 | } 20 | } 21 | } 22 | end 23 | 24 | let(:instance) do 25 | NoteResource.build(payload) 26 | end 27 | 28 | it 'works' do 29 | expect { 30 | expect(instance.save).to eq(true) 31 | }.to change { Note.count }.by(1) 32 | end 33 | end 34 | 35 | describe 'updating' do 36 | let!(:note) { create(:team_note) } 37 | 38 | let(:payload) do 39 | { 40 | data: { 41 | id: note.id.to_s, 42 | type: 'notes', 43 | attributes: { body: 'changed!' } 44 | } 45 | } 46 | end 47 | 48 | let(:instance) do 49 | NoteResource.find(payload) 50 | end 51 | 52 | it 'works' do 53 | expect { 54 | expect(instance.update_attributes).to eq(true) 55 | }.to change { note.reload.updated_at } 56 | .and change { note.body }.to('changed!') 57 | end 58 | end 59 | 60 | describe 'destroying' do 61 | let!(:note) { create(:team_note) } 62 | 63 | let(:instance) do 64 | NoteResource.find(id: note.id) 65 | end 66 | 67 | it 'works' do 68 | expect { 69 | expect(instance.destroy).to eq(true) 70 | }.to change { Note.count }.by(-1) 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /spec/resources/position/reads_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe PositionResource, type: :resource do 4 | describe 'serialization' do 5 | let!(:position) { create(:position, attrs) } 6 | 7 | let(:attrs) do 8 | { 9 | title: 'ruby developer', 10 | active: false 11 | } 12 | end 13 | 14 | it 'works' do 15 | render 16 | data = jsonapi_data[0] 17 | expect(data.id).to eq(position.id) 18 | expect(data.jsonapi_type).to eq('positions') 19 | expect(data.title).to eq('ruby developer') 20 | expect(data.active).to eq(false) 21 | end 22 | end 23 | 24 | describe 'filtering' do 25 | let!(:position1) { create(:position) } 26 | let!(:position2) { create(:position) } 27 | 28 | context 'by id' do 29 | before do 30 | params[:filter] = { id: { eq: position2.id } } 31 | end 32 | 33 | it 'works' do 34 | render 35 | expect(d.map(&:id)).to eq([position2.id]) 36 | end 37 | end 38 | 39 | context 'by current' do 40 | let!(:position1) { create(:position, historical_index: 2) } 41 | let!(:position2) { create(:position, historical_index: 1) } 42 | 43 | before do 44 | params[:filter] = { current: true } 45 | end 46 | 47 | it 'only returns positions where historical index == 1' do 48 | render 49 | expect(d.map(&:id)).to eq([position2.id]) 50 | end 51 | end 52 | end 53 | 54 | describe 'sorting' do 55 | describe 'by id' do 56 | let!(:position1) { create(:position) } 57 | let!(:position2) { create(:position) } 58 | 59 | context 'when ascending' do 60 | before do 61 | params[:sort] = 'id' 62 | end 63 | 64 | it 'works' do 65 | render 66 | expect(d.map(&:id)).to eq([ 67 | position1.id, 68 | position2.id 69 | ]) 70 | end 71 | end 72 | 73 | context 'when descending' do 74 | before do 75 | params[:sort] = '-id' 76 | end 77 | 78 | it 'works' do 79 | render 80 | expect(d.map(&:id)).to eq([ 81 | position2.id, 82 | position1.id 83 | ]) 84 | end 85 | end 86 | end 87 | end 88 | 89 | describe 'sideloading' do 90 | # ... your tests ... 91 | end 92 | end 93 | -------------------------------------------------------------------------------- /spec/resources/position/writes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe PositionResource, type: :resource do 4 | describe 'creating' do 5 | let!(:employee) { create(:employee) } 6 | let!(:department) { create(:department) } 7 | let!(:least_recent) { create(:position, employee: employee) } 8 | let!(:most_recent) { create(:position, employee: employee) } 9 | 10 | let(:payload) do 11 | { 12 | data: { 13 | type: 'positions', 14 | attributes: { }, 15 | relationships: { 16 | employee: { 17 | data: { 18 | id: employee.id.to_s, 19 | type: 'employees' 20 | } 21 | }, 22 | department: { 23 | data: { 24 | id: department.id.to_s, 25 | type: 'departments' 26 | } 27 | } 28 | } 29 | } 30 | } 31 | end 32 | 33 | let(:instance) do 34 | PositionResource.build(payload) 35 | end 36 | 37 | it 'works, updating historical indices' do 38 | expect { 39 | expect(instance.save).to eq(true) 40 | }.to change { Position.count }.by(1) 41 | position = Position.last 42 | expect(position.historical_index).to eq(1) 43 | expect(most_recent.reload.historical_index).to eq(2) 44 | expect(least_recent.reload.historical_index).to eq(3) 45 | end 46 | end 47 | 48 | describe 'updating' do 49 | let!(:position) { create(:position, active: false) } 50 | 51 | let(:payload) do 52 | { 53 | data: { 54 | id: position.id.to_s, 55 | type: 'positions', 56 | attributes: { 57 | title: 'changed!', 58 | active: true 59 | } 60 | } 61 | } 62 | end 63 | 64 | let(:instance) do 65 | PositionResource.find(payload) 66 | end 67 | 68 | it 'works' do 69 | expect { 70 | expect(instance.update_attributes).to eq(true) 71 | }.to change { position.reload.updated_at } 72 | .and change { position.title }.to('changed!') 73 | .and change { position.active }.to(true) 74 | end 75 | end 76 | 77 | describe 'destroying' do 78 | let!(:employee) { create(:employee) } 79 | let!(:position1) do 80 | create(:position, employee: employee, historical_index: 2) 81 | end 82 | let!(:position2) { create(:position, employee: employee) } 83 | 84 | let(:instance) do 85 | PositionResource.find(id: position2.id) 86 | end 87 | 88 | it 'works, updating historical indices' do 89 | expect { 90 | expect(instance.destroy).to eq(true) 91 | }.to change { Position.count }.by(-1) 92 | expect(position1.reload.historical_index).to eq(1) 93 | end 94 | end 95 | end 96 | -------------------------------------------------------------------------------- /spec/resources/task/reads_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe TaskResource, type: :resource do 4 | describe 'serialization' do 5 | let!(:task) { create(:epic, title: 'so epic') } 6 | 7 | it 'works' do 8 | render 9 | data = jsonapi_data[0] 10 | expect(data.id).to eq(task.id) 11 | expect(data.jsonapi_type).to eq('epics') 12 | expect(data.title).to eq('so epic') 13 | end 14 | end 15 | 16 | describe 'filtering' do 17 | let!(:task1) { create(:task) } 18 | let!(:task2) { create(:task) } 19 | 20 | context 'by id' do 21 | before do 22 | params[:filter] = { id: { eq: task2.id } } 23 | end 24 | 25 | it 'works' do 26 | render 27 | expect(d.map(&:id)).to eq([task2.id]) 28 | end 29 | end 30 | end 31 | 32 | describe 'sorting' do 33 | describe 'by id' do 34 | let!(:task1) { create(:task) } 35 | let!(:task2) { create(:task) } 36 | 37 | context 'when ascending' do 38 | before do 39 | params[:sort] = 'id' 40 | end 41 | 42 | it 'works' do 43 | render 44 | expect(d.map(&:id)).to eq([ 45 | task1.id, 46 | task2.id 47 | ]) 48 | end 49 | end 50 | 51 | context 'when descending' do 52 | before do 53 | params[:sort] = '-id' 54 | end 55 | 56 | it 'works' do 57 | render 58 | expect(d.map(&:id)).to eq([ 59 | task2.id, 60 | task1.id 61 | ]) 62 | end 63 | end 64 | end 65 | end 66 | 67 | describe 'sideloading' do 68 | # ... your tests ... 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /spec/resources/task/writes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe TaskResource, type: :resource do 4 | describe 'creating' do 5 | let(:payload) do 6 | { 7 | data: { 8 | type: 'features', 9 | attributes: { } 10 | } 11 | } 12 | end 13 | 14 | let(:instance) do 15 | TaskResource.build(payload) 16 | end 17 | 18 | it 'works' do 19 | expect { 20 | expect(instance.save).to eq(true) 21 | }.to change { Feature.count }.by(1) 22 | end 23 | end 24 | 25 | describe 'updating' do 26 | let!(:task) { create(:task) } 27 | 28 | let(:payload) do 29 | { 30 | data: { 31 | id: task.id.to_s, 32 | type: 'tasks', 33 | attributes: { title: 'changed!' } 34 | } 35 | } 36 | end 37 | 38 | let(:instance) do 39 | TaskResource.find(payload) 40 | end 41 | 42 | it 'works' do 43 | expect { 44 | expect(instance.update_attributes).to eq(true) 45 | }.to change { task.reload.updated_at } 46 | .and change { task.title }.to('changed!') 47 | end 48 | end 49 | 50 | describe 'destroying' do 51 | let!(:task) { create(:task) } 52 | 53 | let(:instance) do 54 | TaskResource.find(id: task.id) 55 | end 56 | 57 | it 'works' do 58 | expect { 59 | expect(instance.destroy).to eq(true) 60 | }.to change { Task.count }.by(-1) 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /spec/resources/team/reads_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe TeamResource, type: :resource do 4 | describe 'serialization' do 5 | let!(:team) { create(:team, name: 'A Team') } 6 | 7 | it 'works' do 8 | render 9 | data = jsonapi_data[0] 10 | expect(data.id).to eq(team.id) 11 | expect(data.jsonapi_type).to eq('teams') 12 | expect(data.name).to eq('A Team') 13 | end 14 | end 15 | 16 | describe 'filtering' do 17 | let!(:team1) { create(:team) } 18 | let!(:team2) { create(:team) } 19 | 20 | context 'by id' do 21 | before do 22 | params[:filter] = { id: { eq: team2.id } } 23 | end 24 | 25 | it 'works' do 26 | render 27 | expect(d.map(&:id)).to eq([team2.id]) 28 | end 29 | end 30 | end 31 | 32 | describe 'sorting' do 33 | describe 'by id' do 34 | let!(:team1) { create(:team) } 35 | let!(:team2) { create(:team) } 36 | 37 | context 'when ascending' do 38 | before do 39 | params[:sort] = 'id' 40 | end 41 | 42 | it 'works' do 43 | render 44 | expect(d.map(&:id)).to eq([ 45 | team1.id, 46 | team2.id 47 | ]) 48 | end 49 | end 50 | 51 | context 'when descending' do 52 | before do 53 | params[:sort] = '-id' 54 | end 55 | 56 | it 'works' do 57 | render 58 | expect(d.map(&:id)).to eq([ 59 | team2.id, 60 | team1.id 61 | ]) 62 | end 63 | end 64 | end 65 | end 66 | 67 | describe 'sideloading' do 68 | # ... your tests ... 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /spec/resources/team/writes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe TeamResource, type: :resource do 4 | describe 'creating' do 5 | let!(:department) { create(:department) } 6 | 7 | let(:payload) do 8 | { 9 | data: { 10 | type: 'teams', 11 | attributes: { }, 12 | relationships: { 13 | department: { 14 | data: { 15 | id: department.id.to_s, 16 | type: 'departments' 17 | } 18 | } 19 | } 20 | } 21 | } 22 | end 23 | 24 | let(:instance) do 25 | TeamResource.build(payload) 26 | end 27 | 28 | it 'works' do 29 | expect { 30 | expect(instance.save).to eq(true) 31 | }.to change { Team.count }.by(1) 32 | end 33 | end 34 | 35 | describe 'updating' do 36 | let!(:team) { create(:team) } 37 | 38 | let(:payload) do 39 | { 40 | data: { 41 | id: team.id.to_s, 42 | type: 'teams', 43 | attributes: { name: 'changed!' } 44 | } 45 | } 46 | end 47 | 48 | let(:instance) do 49 | TeamResource.find(payload) 50 | end 51 | 52 | it 'works' do 53 | expect { 54 | expect(instance.update_attributes).to eq(true) 55 | }.to change { team.reload.updated_at } 56 | .and change { team.name }.to('changed!') 57 | end 58 | end 59 | 60 | describe 'destroying' do 61 | let!(:team) { create(:team) } 62 | 63 | let(:instance) do 64 | TeamResource.find(id: team.id) 65 | end 66 | 67 | it 'works' do 68 | expect { 69 | expect(instance.destroy).to eq(true) 70 | }.to change { Team.count }.by(-1) 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # The `.rspec` file also contains a few flags that are not defaults but that 16 | # users commonly want. 17 | # 18 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 19 | RSpec.configure do |config| 20 | # rspec-expectations config goes here. You can use an alternate 21 | # assertion/expectation library such as wrong or the stdlib/minitest 22 | # assertions if you prefer. 23 | config.expect_with :rspec do |expectations| 24 | # This option will default to `true` in RSpec 4. It makes the `description` 25 | # and `failure_message` of custom matchers include text for helper methods 26 | # defined using `chain`, e.g.: 27 | # be_bigger_than(2).and_smaller_than(4).description 28 | # # => "be bigger than 2 and smaller than 4" 29 | # ...rather than: 30 | # # => "be bigger than 2" 31 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 32 | end 33 | 34 | # rspec-mocks config goes here. You can use an alternate test double 35 | # library (such as bogus or mocha) by changing the `mock_with` option here. 36 | config.mock_with :rspec do |mocks| 37 | # Prevents you from mocking or stubbing a method that does not exist on 38 | # a real object. This is generally recommended, and will default to 39 | # `true` in RSpec 4. 40 | mocks.verify_partial_doubles = true 41 | end 42 | 43 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 44 | # have no way to turn it off -- the option exists only for backwards 45 | # compatibility in RSpec 3). It causes shared context metadata to be 46 | # inherited by the metadata hash of host groups and examples, rather than 47 | # triggering implicit auto-inclusion in groups with matching metadata. 48 | config.shared_context_metadata_behavior = :apply_to_host_groups 49 | 50 | # The settings below are suggested to provide a good initial experience 51 | # with RSpec, but feel free to customize to your heart's content. 52 | =begin 53 | # This allows you to limit a spec run to individual examples or groups 54 | # you care about by tagging them with `:focus` metadata. When nothing 55 | # is tagged with `:focus`, all examples get run. RSpec also provides 56 | # aliases for `it`, `describe`, and `context` that include `:focus` 57 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 58 | config.filter_run_when_matching :focus 59 | 60 | # Allows RSpec to persist some state between runs in order to support 61 | # the `--only-failures` and `--next-failure` CLI options. We recommend 62 | # you configure your source control system to ignore this file. 63 | config.example_status_persistence_file_path = "spec/examples.txt" 64 | 65 | # Limits the available syntax to the non-monkey patched syntax that is 66 | # recommended. For more details, see: 67 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 68 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 69 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 70 | config.disable_monkey_patching! 71 | 72 | # Many RSpec users commonly either run the entire suite or an individual 73 | # file, and it's useful to allow more verbose output when running an 74 | # individual spec file. 75 | if config.files_to_run.one? 76 | # Use the documentation formatter for detailed output, 77 | # unless a formatter has already been configured 78 | # (e.g. via a command-line flag). 79 | config.default_formatter = 'doc' 80 | end 81 | 82 | # Print the 10 slowest examples and example groups at the 83 | # end of the spec run, to help surface which specs are running 84 | # particularly slow. 85 | config.profile_examples = 10 86 | 87 | # Run specs in random order to surface order dependencies. If you find an 88 | # order dependency and want to debug it, you can fix the order by providing 89 | # the seed, which is printed after each run. 90 | # --seed 1234 91 | config.order = :random 92 | 93 | # Seed global randomization in this process using the `--seed` CLI option. 94 | # Setting this allows you to use `--seed` to deterministically reproduce 95 | # test failures related to randomization by passing the same `--seed` value 96 | # as the one that triggered the failure. 97 | Kernel.srand config.seed 98 | =end 99 | end 100 | -------------------------------------------------------------------------------- /storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphiti-api/employee_directory/4930916e869f1f5d271d6ac9c10fd34f0f13d2b0/storage/.keep -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphiti-api/employee_directory/4930916e869f1f5d271d6ac9c10fd34f0f13d2b0/tmp/.keep -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphiti-api/employee_directory/4930916e869f1f5d271d6ac9c10fd34f0f13d2b0/vendor/.keep --------------------------------------------------------------------------------