diff --git a/.env.sample b/.env.sample index 09cc8c984..d909e9057 100644 --- a/.env.sample +++ b/.env.sample @@ -18,11 +18,11 @@ PUSHER_APP_ID=1234 PUSHER_APP_KEY=123456 PUSHER_APP_SECRET=34214341 PUSHER_APP_CLUSTER=123 -PUSHER_SOCKET_URL='ws://ws-123.pusher.com/app/123456' -PUSHER_HOST="127.0.0.1" +VITE_PUSHER_SOCKET_URL='ws://ws-123.pusher.com/app/123456' +PUSHER_HOST="pusherfake" PUSHER_PORT="8888" -PUSHER_WS_HOST="127.0.0.1" -PUSHER_WS_PORT="45449" +VITE_PUSHER_WS_HOST="127.0.0.1" +VITE_PUSHER_WS_PORT="45449" EARLY_V2_EMAIL="@codeminer42.com" GOOGLE_ANALYTICS_ID= GLOBAL_ALERT_TEXT= diff --git a/Dockerfile b/Dockerfile index f00b12ac2..fba295f5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,18 @@ COPY Gemfile.lock Gemfile.lock COPY yarn.lock yarn.lock COPY .env.sample .env +ADD pusher-fake-entrypoint.sh /tmp/pusher-fake-entrypoint.sh + +ENV PUSHER_APP_ID=1234 \ + PUSHER_APP_KEY=123456 \ + PUSHER_APP_SECRET=34214341 \ + PUSHER_PORT=8888 \ + PUSHER_WS_PORT=45449 + +EXPOSE $PUSHER_WS_PORT $PUSHER_PORT + +CMD ["/tmp/pusher-fake-entrypoint.sh"] + RUN bundle install WORKDIR /app diff --git a/app/assets/javascripts/pusherSockets.js b/app/assets/javascripts/pusherSockets.js index 524b1c080..e288c708d 100644 --- a/app/assets/javascripts/pusherSockets.js +++ b/app/assets/javascripts/pusherSockets.js @@ -6,7 +6,7 @@ const matchPusherUrl = url => { }; export const subscribeToProjectChanges = (project, callback) => { - const pusherUrl = process.env.PUSHER_SOCKET_URL || ''; + const pusherUrl = import.meta.env.VITE_PUSHER_SOCKET_URL || ''; const [ _, pusherCluster, @@ -38,8 +38,8 @@ const getProjectSocket = (apiKey, apiCluster) => { }) : new Pusher(apiKey,{ cluster: apiCluster, - wsHost: process.env.PUSHER_WS_HOST, - wsPort: process.env.PUSHER_WS_PORT, + wsHost: import.meta.env.VITE_PUSHER_WS_HOST, + wsPort: import.meta.env.VITE_PUSHER_WS_PORT, encrypted: false, disableStats: true }) diff --git a/app/controllers/beta/projects_controller.rb b/app/controllers/beta/projects_controller.rb index be01228db..86c4fbf57 100644 --- a/app/controllers/beta/projects_controller.rb +++ b/app/controllers/beta/projects_controller.rb @@ -2,8 +2,9 @@ class Beta::ProjectsController < ApplicationController before_action :set_fluid_layout def show - @project_id = params[:id] - @project = current_user.projects.friendly.find @project_id + project_slug = params[:id] + @project = current_user.projects.friendly.find project_slug + @project_id = @project.id authorize @project, policy_class: Beta::ProjectPolicy update_current_team diff --git a/docker-compose.yml b/docker-compose.yml index 726433e75..4b3e9c7cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -69,6 +69,20 @@ services: - ./node_modules:/app/node_modules command: sh -c "bundle binstubs bundler --force && ruby ./bin/vite dev" + pusherfake: + build: . + ports: + - "8888:8888" # Pusher-Fake web port + - "45449:45449" # Pusher-Fake socket port + volumes: + - .:/app + environment: + PUSHER_APP_ID: 1234 + PUSHER_WS_PORT: 45449 + PUSHER_PORT: 8888 + PUSHER_APP_KEY: 123456 + PUSHER_APP_SECRET: 34214341 + adminer: image: adminer:4.8.1 environment: diff --git a/pusher-fake-entrypoint.sh b/pusher-fake-entrypoint.sh new file mode 100755 index 000000000..61e23d19f --- /dev/null +++ b/pusher-fake-entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +pusher-fake -i $PUSHER_APP_ID --socket-host 0.0.0.0 --socket-port $PUSHER_WS_PORT --web-host 0.0.0.0 --web-port $PUSHER_PORT -k $PUSHER_APP_KEY -s $PUSHER_APP_SECRET diff --git a/spec/javascripts/components/projects/project_board_spec.js b/spec/javascripts/components/projects/project_board_spec.js index a846fedce..2d01b89b8 100644 --- a/spec/javascripts/components/projects/project_board_spec.js +++ b/spec/javascripts/components/projects/project_board_spec.js @@ -3,6 +3,10 @@ import { shallow } from 'enzyme'; import { ProjectBoard } from 'components/projects/ProjectBoard'; import storyFactory from '../../support/factories/storyFactory'; +jest.mock('../../../../app/assets/javascripts/pusherSockets', () => ({ + subscribeToProjectChanges: jest.fn(), +})); + describe('', () => { const render = props => { const defaultProps = {