mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Add Boards management to sitesettings (#107)
This commit is contained in:
committed by
GitHub
parent
7b8a4d6709
commit
6be2394dc5
@@ -2,6 +2,6 @@ FactoryBot.define do
|
||||
factory :board do
|
||||
sequence(:name) { |n| "Board#{n}" }
|
||||
description { 'My fantastic board' }
|
||||
order { 1 }
|
||||
sequence(:order) { |n| n }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,12 +30,19 @@ RSpec.describe Board, type: :model do
|
||||
expect(empty_description_board).to be_valid
|
||||
end
|
||||
|
||||
it 'automatically sets order to last order if not specified' do
|
||||
order = 10
|
||||
board1 = FactoryBot.create(:board, order: order)
|
||||
board2 = Board.new
|
||||
it 'is Orderable' do
|
||||
# I didn't used FactoryBot because it didn't apply
|
||||
# the custom logic to the 'order' column
|
||||
|
||||
board1 = Board.create(name: 'b1', order: 0)
|
||||
board2 = Board.create(name: 'b2')
|
||||
board3 = Board.new
|
||||
|
||||
expect(board1.order).to eq(order)
|
||||
expect(board2.order).to eq(order + 1)
|
||||
expect(board2.order).to eq(1)
|
||||
expect(board3.order).to eq(2)
|
||||
|
||||
board1.destroy
|
||||
|
||||
expect(board2.reload.order).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,18 +62,19 @@ RSpec.describe PostStatus, type: :model do
|
||||
expect(roadmap.second).to eq(post_status2)
|
||||
end
|
||||
|
||||
it 'automatically sets a random color if not specified' do
|
||||
post_status1 = PostStatus.new
|
||||
it 'is Orderable' do
|
||||
# I didn't used FactoryBot because it didn't apply
|
||||
# the custom logic to the 'order' column
|
||||
|
||||
expect(post_status1.color).to match(/\A#(?:[0-9a-fA-F]{3}){1,2}\z/)
|
||||
end
|
||||
|
||||
it 'automatically sets order to last order if not specified' do
|
||||
order = 10
|
||||
post_status1 = FactoryBot.create(:post_status, order: order)
|
||||
post_status2 = PostStatus.new
|
||||
post_status1 = PostStatus.create(name: 'ps1', color: '#000000', order: 0)
|
||||
post_status2 = PostStatus.create(name: 'ps2', color: '#000000')
|
||||
post_status3 = PostStatus.new
|
||||
|
||||
expect(post_status1.order).to eq(order)
|
||||
expect(post_status2.order).to eq(order + 1)
|
||||
expect(post_status2.order).to eq(1)
|
||||
expect(post_status3.order).to eq(2)
|
||||
|
||||
post_status1.destroy
|
||||
|
||||
expect(post_status2.reload.order).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,13 +6,26 @@ RSpec.describe 'boards routing', :aggregate_failures, type: :routing do
|
||||
controller: 'boards', action: 'show', id: '1'
|
||||
)
|
||||
|
||||
expect(get: '/boards').not_to be_routable
|
||||
expect(get: '/boards').to route_to(
|
||||
controller: 'boards', action: 'index'
|
||||
)
|
||||
|
||||
expect(get: '/boards/new').not_to route_to(
|
||||
controller: 'boards', action: 'new'
|
||||
)
|
||||
|
||||
expect(get: '/boards/1/edit').not_to be_routable
|
||||
expect(post: '/boards').not_to be_routable
|
||||
expect(patch: '/boards/1').not_to be_routable
|
||||
expect(delete: '/boards/1').not_to be_routable
|
||||
|
||||
expect(post: '/boards').to route_to(
|
||||
controller: 'boards', action: 'create'
|
||||
)
|
||||
|
||||
expect(patch: '/boards/1').to route_to(
|
||||
controller: 'boards', action: 'update', id: '1'
|
||||
)
|
||||
|
||||
expect(delete: '/boards/1').to route_to(
|
||||
controller: 'boards', action: 'destroy', id: '1'
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -9,7 +9,12 @@ Capybara.register_driver :chrome_headless do |app|
|
||||
options.add_argument('--disable-dev-shm-usage')
|
||||
options.add_argument('--window-size=1400,1400')
|
||||
|
||||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
|
||||
capabilities = [
|
||||
options,
|
||||
Selenium::WebDriver::Remote::Capabilities.chrome
|
||||
]
|
||||
|
||||
Capybara::Selenium::Driver.new(app, browser: :chrome, capabilities: capabilities)
|
||||
end
|
||||
|
||||
Capybara.javascript_driver = :chrome_headless
|
||||
|
||||
@@ -9,7 +9,6 @@ feature 'sign up', type: :system do
|
||||
fill_in 'Email', with: user.email
|
||||
fill_in 'Password', with: user.password
|
||||
fill_in 'Password confirmation', with: user.password
|
||||
check 'Notifications enabled'
|
||||
click_button 'Sign up'
|
||||
end
|
||||
|
||||
@@ -76,16 +75,4 @@ feature 'sign up', type: :system do
|
||||
expect_to_be_on_sign_up_page
|
||||
expect(page).to have_css('.alert')
|
||||
end
|
||||
|
||||
scenario 'with disabled notifications' do
|
||||
visit new_user_registration_path
|
||||
fill_in 'Full name', with: user.full_name
|
||||
fill_in 'Email', with: user.email
|
||||
fill_in 'Password', with: user.password
|
||||
fill_in 'Password confirmation', with: user.password
|
||||
uncheck 'Notifications enabled'
|
||||
click_button 'Sign up'
|
||||
|
||||
expect(User.last.notifications_enabled).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user