diff --git a/app/admin/admin_health_rating_types.rb b/app/admin/admin_health_rating_types.rb new file mode 100644 index 0000000..b777800 --- /dev/null +++ b/app/admin/admin_health_rating_types.rb @@ -0,0 +1,34 @@ +ActiveAdmin.register HealthRatingType do + permit_params :name, :score, :weight, :threshold_min, :threshold_max, :created_by_id, :updated_by_id + + index do + selectable_column + id_column + column :name + column :score + column :weight + column :threshold_min + column :threshold_max + column :created_at + actions + end + + filter :name + filter :created_at + + form do |f| + f.inputs do + f.input :name + f.input :score + f.input :weight + f.input :threshold_min + f.input :threshold_max + # f.hidden_field :created_by_id, value: User.first.id # FIXME + # f.hidden_field :updated_by_id, value: User.first.id # FIXME + + f.input :created_by_id, :input_html => { :value => User.first.id }, as: :hidden + f.input :updated_by_id, :input_html => { :value => User.first.id }, as: :hidden + end + f.actions + end +end \ No newline at end of file diff --git a/spec/features/health_rating_type_spec.rb b/spec/features/health_rating_type_spec.rb new file mode 100644 index 0000000..e47e080 --- /dev/null +++ b/spec/features/health_rating_type_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +feature 'Health rating type management', js: true do + before do + sign_in(create(:user, admin: true)) + end + + describe 'health rating types' do + it 'admins can create health rating types' do + visit root_path + + page.find('.user-dropdown').hover + click_link 'Admin' + click_link 'Health Rating Types' + + click_link 'New Health Rating Type', visible: false + fill_in 'Name', with: 'New Health Rating Type!' + click_button 'Create Health rating type' + + expect(page.find('.flash_notice')).to have_content "Health rating type was successfully created." + + # expect(page).to have_css('table#records tbody tr', count: 1) + end + end +end \ No newline at end of file