Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/pusher fake config #880

Merged
merged 11 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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=
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions app/assets/javascripts/pusherSockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
})
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/beta/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions pusher-fake-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions spec/javascripts/components/projects/project_board_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<ProjectBoard />', () => {
const render = props => {
const defaultProps = {
Expand Down
Loading