diff --git a/Dockerfile b/Dockerfile index bbb57a37..fe0e5018 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ COPY . ${APP_ROOT}/ # Compile assets if production # SECRET_KEY_BASE=1 is a workaround (see https://github.com/rails/rails/issues/32947) -RUN if [ "$ENVIRONMENT" = "production" ]; then SECRET_KEY_BASE=1 RAILS_ENV=production bundle exec rake assets:precompile; fi +RUN if [ "$ENVIRONMENT" = "production" ]; then RAILS_ENV=development bundle exec rake webpacker:compile; fi ### ### Dev stage ### diff --git a/spec/system/likes_spec.rb b/spec/system/likes_spec.rb index ec2a8432..7f60ba37 100644 --- a/spec/system/likes_spec.rb +++ b/spec/system/likes_spec.rb @@ -25,81 +25,76 @@ feature 'likes', type: :system, js: true do post2 end - # NOTE - # For some weird reason, all these tests fails when - # runned on GitHub Actions runners. They pass locally, - # but I'll leave them commented out for now. + context 'in post list of Board component' do + it 'renders correctly for each post' do + visit board_path(board) - # context 'in post list of Board component' do - # it 'renders correctly for each post' do - # visit board_path(board) + within board_container do + expect(page).to have_css(like_button_container_selector, count: 2) + expect(page).to have_css(like_button_selector, count: 2) + # expect(page).to have_css(likes_count_label_selector, count: 2) + end + end - # within board_container do - # expect(page).to have_css(like_button_container_selector, count: 2) - # expect(page).to have_css(like_button_selector, count: 2) - # # expect(page).to have_css(likes_count_label_selector, count: 2) - # end - # end + it 'redirects when user not logged in' do + visit board_path(board) - # it 'redirects when user not logged in' do - # visit board_path(board) + within board_container do + find(like_button_selector, match: :first).click + expect(page.current_path).to eq(new_user_session_path) + end + end - # within board_container do - # find(like_button_selector, match: :first).click - # expect(page.current_path).to eq(new_user_session_path) - # end - # end + it 'likes and unlikes' do + user.confirm + sign_in user + visit board_path(board) - # it 'likes and unlikes' do - # user.confirm - # sign_in user - # visit board_path(board) + within board_container do + first_like_button = find(like_button_selector, match: :first) + like_container = find(like_button_container_selector, match: :first) - # within board_container do - # first_like_button = find(like_button_selector, match: :first) - # like_container = find(like_button_container_selector, match: :first) + # starts at zero likes + expect(like_container).to have_content(0) - # # starts at zero likes - # expect(like_container).to have_content(0) + # like + first_like_button.click + expect(like_container).to have_content(1) - # # like - # first_like_button.click - # expect(like_container).to have_content(1) + # unlike + first_like_button.click + expect(like_container).to have_content(0) + end + end + end - # # unlike - # first_like_button.click - # expect(like_container).to have_content(0) - # end - # end - # end + context 'in Post component' do + it 'renders correctly' do + visit post_path(post1) - # context 'in Post component' do - # it 'renders correctly' do - # visit post_path(post1) + expect(page).to have_css(like_button_container_selector) + expect(page).to have_css(like_button_selector) + # expect(page).to have_css(likes_count_label_selector) + end - # expect(page).to have_css(like_button_container_selector) - # expect(page).to have_css(like_button_selector) - # # expect(page).to have_css(likes_count_label_selector) - # end + # Don't know why it doesn't work... + # it 'likes and unlikes' do + # user.confirm + # sign_in user + # visit post_path(post1) - # # Don't know why it doesn't work... - # # it 'likes and unlikes' do - # # user.confirm - # # sign_in user - # # visit post_path(post1) + # within like_button_container_selector do + # # starts at zero likes + # expect(page).to have_content(0) - # # within like_button_container_selector do - # # # starts at zero likes - # # expect(page).to have_content(0) + # # like + # find(like_button_selector).click + # expect(page).to have_content(1) - # # # like - # # find(like_button_selector).click - # # expect(page).to have_content(1) - - # # # unlike - # # find(like_button_selector).click - # # expect(page).to have_content(0) - # # end - # # end - # end + # # unlike + # find(like_button_selector).click + # expect(page).to have_content(0) + # end + # end + end end \ No newline at end of file diff --git a/spec/system/post_spec.rb b/spec/system/post_spec.rb index be035af4..7c107ab1 100644 --- a/spec/system/post_spec.rb +++ b/spec/system/post_spec.rb @@ -86,6 +86,7 @@ feature 'post', type: :system, js: true do visit post_path(post) post_count = Post.count + post_board = post.board within post_container_selector do find('.deleteAction').click @@ -95,7 +96,7 @@ feature 'post', type: :system, js: true do alert.accept end - expect(page).to have_current_path(board_path(post.board)) + expect(page).to have_current_path(board_path(post_board)) expect(Post.count).to eq(post_count - 1) end end \ No newline at end of file