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

Protect routes with functional tests #834

Closed
Tracked by #801
Georjane opened this issue Jan 11, 2022 · 9 comments · Fixed by #835
Closed
Tracked by #801

Protect routes with functional tests #834

Georjane opened this issue Jan 11, 2022 · 9 comments · Fixed by #835

Comments

@Georjane
Copy link
Collaborator

Georjane commented Jan 11, 2022

Hi @jywarren @Tlazypanda @TildaDares 👋🏽
For the functional tests, I noticed that we have about 13 controllers in the SW but we have functional tests for just about 9 controllers. So the following controllers are not being tested, device_controller, macros_controller, match_controller, and application_controller.

Just to be sure that I would be writing tests for these controllers?
Also, I was wondering what Macros in the macros_controller are?

Thank you! 🙏🏽

@Georjane
Copy link
Collaborator Author

Georjane commented Jan 11, 2022

I tried running the following test on the macros_controller that passed but I did not exactly understand the response I was getting. I don't understand what macros are.

# frozen_string_literal: true

require 'test_helper'

class MacrosControllerTest < ActionController::TestCase
  test 'should get macros index' do
    get :index
    assert_response :success
  end
end

@TildaDares
Copy link
Member

Hi Jane, what kind of responses did you get?

I don't know if this helps you understand what macros do

<p><a class="macros">Macros</a> are small scripts that allow you to manipulate or transform your data. Use those shared by others or <a href="//publiclab.org/wiki/spectral-workbench-api">write your own in JavaScript</a>.</p>

@TildaDares
Copy link
Member

TildaDares commented Jan 11, 2022

I also found this article on https://publiclab.org/wiki/spectral-workbench-api-v1#Macros on Public Lab. It's deprecated but it should give you a better sense of what Macros are.

@Georjane
Copy link
Collaborator Author

Hi Jane, what kind of responses did you get?

I don't know if this helps you understand what macros do

<p><a class="macros">Macros</a> are small scripts that allow you to manipulate or transform your data. Use those shared by others or <a href="//publiclab.org/wiki/spectral-workbench-api">write your own in JavaScript</a>.</p>

I tried accessing the enpoint /macros locally but I was getting the following error
image

When I try accessing it on the live version I have this page
image

@Georjane
Copy link
Collaborator Author

I also found this article on https://publiclab.org/wiki/spectral-workbench-api-v1#Macros on Public Lab. It's deprecated but it should give you a better sense oof what Macros are.

ohhh I understand macros now. Thank you very much @TildaDares
I think I understand the error now

@Georjane
Copy link
Collaborator Author

Now able to create a macro but got the following error from the show method
image

@TildaDares
Copy link
Member

@Georjane I think find_by_title method is supposed to be passed one argument. You can try this format and see if it works
https://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find_by

@Georjane
Copy link
Collaborator Author

@Georjane I think find_by_title method is supposed to be passed one argument. You can try this format and see if it works https://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find_by

thanks for the link @TildaDares
let me read more on this

@Georjane
Copy link
Collaborator Author

Georjane commented Feb 8, 2022

@TildaDares thank you, @Tlazypanda helped me out with the following syntax that works
@macro = Macro.find_by :title params[:id], conditions: { user_id: @user.id }, order: 'id DESC'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants