diff --git a/.rubocop.yml b/.rubocop.yml index 8f346897..8c6cedc9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,9 @@ inherit_from: .rubocop_todo.yml +AllCops: + Exclude: + - 'db/schema.rb' + # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -7,7 +11,10 @@ Style/StringLiterals: Exclude: - 'db/**/*' -# Configuration parameters: CountComments, ExcludedMethods. -Metrics/BlockLength: +#turn off end of line checks, git will fix this +EndOfLine: + Enabled: false + +Metrics/ClassLength: Exclude: - - 'db/schema.rb' + - 'test/models/user_test.rb' \ No newline at end of file diff --git a/Makefile b/Makefile index b9f79c8c..3af54365 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,42 @@ -RAILS_CONTAINER := web +include Makefile.in .PHONY: all all: run +.PHONY: nuke +nuke: + $(DOCKER) system prune -a --volumes + +.PHONY: +minty-fresh: + $(DOCKER_COMPOSE) down --rmi all --volumes + +.PHONY: rmi +rmi: + $(DOCKER) images -q | xargs docker rmi -f + +.PHONY: rmdi +rmdi: + $(DOCKER) images -a --filter=dangling=true -q | xargs $(DOCKER) rmi + +.PHONY: rm-exited-containers +rm-exited-containers: + $(DOCKER) ps -a -q -f status=exited | xargs $(DOCKER) rm -v + +.PHONY: fresh-restart +fresh-restart: minty-fresh setup test run + .PHONY: console-sandbox - console-sandbox: - docker-compose run ${RAILS_CONTAINER} rails console --sandbox +console-sandbox: + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rails console --sandbox .PHONY: run run: - docker-compose up --build + $(DOCKER_COMPOSE) up --build .PHONY: bg bg: - docker-compose up --build -d + $(DOCKER_COMPOSE) up --build -d .PHONY: open open: @@ -21,52 +44,53 @@ open: .PHONY: build build: - docker-compose build + $(DOCKER_COMPOSE) build .PHONY: console console: - docker-compose run ${RAILS_CONTAINER} rails console + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rails console .PHONY: routes routes: - docker-compose run ${RAILS_CONTAINER} rake routes + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rake routes .PHONY: db_create db_create: - docker-compose run ${RAILS_CONTAINER} rake db:create + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rake db:create .PHONY: db_migrate db_migrate: - docker-compose run ${RAILS_CONTAINER} rake db:migrate + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rake db:migrate .PHONY: db_status db_status: - docker-compose run ${RAILS_CONTAINER} rake db:migrate:status + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rake db:migrate:status .PHONY: db_rollback db_rollback: - docker-compose run ${RAILS_CONTAINER} rake db:rollback + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rake db:rollback .PHONY: db_seed db_seed: - docker-compose run ${RAILS_CONTAINER} rake db:seed + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rake db:seed .PHONY: test test: bg - docker-compose run operationcode-psql bash -c "while ! psql --host=operationcode-psql --username=postgres -c 'SELECT 1'; do sleep 5; done;" - docker-compose run ${RAILS_CONTAINER} bash -c 'export RAILS_ENV=test && rake db:test:prepare && rake test && rubocop' + $(DOCKER_COMPOSE) run operationcode-psql bash -c "while ! psql --host=operationcode-psql --username=postgres -c 'SELECT 1'; do sleep 5; done;" + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) bash -c 'export RAILS_ENV=test && rake db:test:prepare && rake test || echo -e "$(RED)Unit tests have failed$(NC)" ' + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) bash -c 'rubocop' || echo -e "$(RED)Linting has failed$(NC)" .PHONY: rubocop rubocop: - docker-compose run ${RAILS_CONTAINER} rubocop + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rubocop .PHONY: rubocop_auto_correct rubocop_auto_correct: - docker-compose run ${RAILS_CONTAINER} rubocop -a --auto-correct + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) rubocop -a --auto-correct .PHONY: bundle bundle: - docker-compose run ${RAILS_CONTAINER} bash -c 'cd /app && bundle' + $(DOCKER_COMPOSE) run $(RAILS_CONTAINER) bash -c 'cd /app && bundle' setup: build db_create db_migrate diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..49f66a6d --- /dev/null +++ b/Makefile.in @@ -0,0 +1,10 @@ +RAILS_CONTAINER:= web +DOCKER_COMPOSE:= docker-compose +DOCKER:= docker +RED=\033[0;31m +GREEN=\032[0;32m +NC=\033[0m + + +.DELETE_ON_ERROR: +.SILENT: diff --git a/apiary.apib b/apiary.apib index 386999e1..0537474a 100644 --- a/apiary.apib +++ b/apiary.apib @@ -451,7 +451,7 @@ API endpoints that Operation Code's Rails backend makes available to its React f "state": "VA", "country": "USA", "description": "Our job is fun!", - "status": "active", + "open": false, "remote": false, "created_at": "2018-06-01T16:21:59.462Z", "updated_at": "2018-06-01T16:21:59.462Z" diff --git a/app/admin/job.rb b/app/admin/job.rb index 3af7982b..07de9d85 100644 --- a/app/admin/job.rb +++ b/app/admin/job.rb @@ -1,5 +1,5 @@ ActiveAdmin.register Job do - permit_params :title, :source_url, :source, :city, :state, :country, :description, :status, :remote + permit_params :title, :source_url, :source, :city, :state, :country, :description, :is_open, :remote index do selectable_column @@ -12,7 +12,7 @@ column :state column :country column :description - column :status + column :is_open column :remote actions @@ -27,7 +27,7 @@ f.input :state f.input :country f.input :description - f.input :status + f.input :is_open f.input :remote end diff --git a/db/migrate/20180531004341_create_jobs.rb b/db/migrate/20180531004341_create_jobs.rb index 7e557d66..a97e39ad 100644 --- a/db/migrate/20180531004341_create_jobs.rb +++ b/db/migrate/20180531004341_create_jobs.rb @@ -8,7 +8,7 @@ def change t.string :state t.string :country t.text :description - t.string :status + t.boolean :is_open, default: true t.boolean :remote, default: false t.timestamps diff --git a/db/schema.rb b/db/schema.rb index 955804a3..84871bd7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,6 +11,7 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20180531004341) do + # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -123,7 +124,7 @@ t.string "state" t.string "country" t.text "description" - t.string "status" + t.boolean "is_open", default: true t.boolean "remote", default: false t.datetime "created_at", null: false t.datetime "updated_at", null: false diff --git a/db/seeds.rb b/db/seeds.rb index 6f64707f..d4bcfdec 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -33,7 +33,7 @@ end # Create jobs -Job.create!(title: "A great job", source_url: "www.applyhere.com", source: "Company A", city: "Virginia Beach", state: "VA", country: "USA", description: "Our job is fun!", status: "active", remote: "false") +Job.create!(title: "A great job", source_url: "www.applyhere.com", source: "Company A", city: "Virginia Beach", state: "VA", country: "USA", description: "Our job is fun!", is_open: true, remote: false) # Create team members SeedTeamMembers.seed_all diff --git a/test/factories/jobs.rb b/test/factories/jobs.rb index ce61eebc..5f5515a2 100644 --- a/test/factories/jobs.rb +++ b/test/factories/jobs.rb @@ -7,7 +7,7 @@ state Faker::Address.state country Faker::Address.country description Faker::Lorem.paragraph - status 'active' + is_open true remote false end end